@ -16,70 +16,66 @@ Developers can work on PaddlePaddle using Docker. This allows
developers to work on different platforms -- Linux, Mac OS X, and
developers to work on different platforms -- Linux, Mac OS X, and
Windows -- in a consistent way.
Windows -- in a consistent way.
The general development workflow with Docker and CMake is as follows:
1. Build the Development Environment as a Docker Image
1. Get the source code of Paddle:
.. code-block :: bash
.. code-block :: bash
git clone https://github.com/PaddlePaddle/Paddle.git
git clone --recursive https://github.com/PaddlePaddle/Paddle
cd Paddle
docker build -t paddle:dev -f paddle/scripts/docker/Dockerfile .
2. Build a development Docker image :code: `paddle:dev` from the source
Note that by default :code: `docker build` wouldn't import source
code. This image contains all the development tools an d
tree into the image and build it. If we want to do that, we nee d
dependencies of PaddlePaddle.
to set a build arg:
.. code-block :: bash
.. code-block :: bash
cd paddle
docker build -t paddle:dev -f paddle/scripts/docker/Dockerfile --build-arg BUILD_AND_INSTALL=ON .
docker build -t paddle:dev -f paddle/scripts/docker/Dockerfile .
Sometimes docker build might suffer from a slow network connection to the official Ubuntu apt-source servers. In such case, we can specify an apt-source mirror server that is geologically nearer to us. In the following example, we specified an apt-source server that responds fast in China.You can specify the UBUNTU MIRROR with :code: `--build-arg UBUNTU_MIRROR` like the example below.
.. code-block :: bash
docker build \
--build-arg UBUNTU_MIRROR="http://mirrors.163.com" \
-t paddle:dev \
-f paddle/scripts/docker/Dockerfile .
1. Run the Development Environment
3. Run the image as a container and mounting local source code
Once we got the image :code: `paddle:dev` , we can use it to develop
directory into the container. This allows us to change the code on
Paddle by mounting the local source code tree into a container that
the host and build it within the container.
runs the image:
.. code-block :: bash
.. code-block :: bash
docker run -d -p 2202:22 -v $PWD:/paddle paddle:dev
This runs a container of the development environment Docker image
with the local source tree mounted to :code: `/paddle` of the
container.
docker run \
Note that the default entry-point of :code: `paddle:dev` is
-d \
:code: `sshd` , and above :code: `docker run` commands actually starts
--name paddle \
an SSHD server listening on port 2202. This allows us to log into
-p 2022:22 \
this container with:
-v $PWD:/paddle \
paddle:dev
where :code: `-d` makes the container running in background,
.. code-block :: bash
:code: `--name paddle` allows us to run a nginx container to serve
ssh root@localhost -p 2202
documents in this container, :code: `-p 2022:22` allows us to SSH
into this container, :code: `-v $PWD:/paddle` shares the source code
on the host with the container.
4. SSH into the container:
Usually, I run above commands on my Mac. I can also run them on a
GPU server :code: `xxx.yyy.zzz.www` and ssh from my Mac to it:
.. code-block :: bash
.. code-block :: bash
my-mac$ ssh root@xxx.yyy.zzz.www -p 2202
ssh root@localhost -p 2022
1. Build and Install Using the Development Environment
5. We can edit the source code in the container or on this host. Then
Once I am in the container, I can use
we can build using cmake
:code: `paddle/scripts/docker/build.sh` to build, install, and test
Paddle:
.. code-block :: bash
.. code-block :: bash
/paddle/paddle/scripts/docker/build.sh
This builds everything about Paddle in :code: `/paddle/build` . And
we can run unit tests there:
cd /paddle # where paddle source code has been mounted into the container
.. code-block :: bash
mkdir -p build
cd /paddle/build
cd build
ctest
cmake -DWITH_TESTING=ON ..
make -j `nproc`
CTEST_OUTPUT_ON_FAILURE=1 ctest
CPU-only and GPU Images
CPU-only and GPU Images