Skip to content

Commit 1cbd943

Browse files
committed
Update documents
1 parent 1c4d719 commit 1cbd943

File tree

1 file changed

+48
-46
lines changed

1 file changed

+48
-46
lines changed
Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,83 @@
1-
Using and Building Docker Images
2-
================================
1+
PaddlePaddle in Docker Containers
2+
=================================
33

4-
We release PaddlePaddle in the form of `Docker <https://www.docker.com/>`_ images on `dockerhub.com <https://hub.docker.com/r/paddledev/paddle/>`_. Running as Docker containers is currently the only officially-supported way to running PaddlePaddle.
4+
Docker container is currently the only officially-supported way to
5+
running PaddlePaddle. This is reasonable as Docker now runs on all
6+
major operating systems including Linux, Mac OS X, and Windows.
7+
Please be aware that you will need to change `Dockers settings
8+
<https://github.com/PaddlePaddle/Paddle/issues/627>`_ to make full use
9+
of your hardware resource on Mac OS X and Windows.
510

6-
Run Docker images
7-
-----------------
811

9-
For each version of PaddlePaddle, we release 4 variants of Docker images:
12+
CPU-only and GPU Images
13+
-----------------------
1014

11-
+-----------------+-------------+-------+
12-
| | CPU AVX | GPU |
13-
+=================+=============+=======+
14-
| cpu | yes | no |
15-
+-----------------+-------------+-------+
16-
| cpu-noavx | no | no |
17-
+-----------------+-------------+-------+
18-
| gpu | yes | yes |
19-
+-----------------+-------------+-------+
20-
| gpu-noavx | no | yes |
21-
+-----------------+-------------+-------+
15+
For each version of PaddlePaddle, we release 2 Docker images, a
16+
CPU-only one and a CUDA GPU one. We do so by configuring
17+
`dockerhub.com <https://hub.docker.com/r/paddledev/paddle/>`_
18+
automatically runs the following commands:
2219

23-
We run the following command on Linux to check if the CPU supports :code:`AVX`.
20+
.. code-block:: base
2421
25-
.. code-block:: bash
22+
docker build -t paddle:cpu-noavx -f paddle/scripts/docker/Dockerfile .
23+
docker build -t paddle:gpu-noavx -f paddle/scripts/docker/Dockerfile.gpu .
2624
27-
if cat /proc/cpuinfo | grep -i avx; then echo Yes; else echo No; fi
2825
29-
On Mac OS X, we need to run
26+
To run the CPU-only image as an interactive container:
3027

3128
.. code-block:: bash
3229
33-
sysctl -a | grep machdep.cpu.leaf7_features
34-
30+
docker run -it --rm paddledev/paddle:cpu-latest /bin/bash
3531
36-
Once we determine the proper variant, we can cope with the Docker image tag name by appending the version number. For example, the following command runs the AVX-enabled image of the most recent version:
32+
or, we can run it as a daemon container
3733

3834
.. code-block:: bash
3935
40-
docker run -it --rm paddledev/paddle:cpu-latest /bin/bash
36+
docker run -d -p 2202:22 paddledev/paddle:cpu-latest
4137
42-
To run a GPU-enabled image, you need to install CUDA and let Docker knows about it:
38+
and SSH to this container using password :code:`root`:
4339

4440
.. code-block:: bash
4541
46-
export CUDA_SO="$(\ls /usr/lib64/libcuda* | xargs -I{} echo '-v {}:{}') $(\ls /usr/lib64/libnvidia* | xargs -I{} echo '-v {}:{}')"
47-
export DEVICES=$(\ls /dev/nvidia* | xargs -I{} echo '--device {}:{}')
48-
docker run ${CUDA_SO} ${DEVICES} -it paddledev/paddle:gpu-latest
49-
50-
The default entry point of all our Docker images starts the OpenSSH server. To run PaddlePaddle and to expose OpenSSH port to 2202 on the host computer:
42+
ssh -p 2202 root@localhost
5143
52-
.. code-block:: bash
44+
An advantage of using SSH is that we can connect to PaddlePaddle from
45+
more than one terminals. For example, one terminal running vi and
46+
another one running Python interpreter. Another advantage is that we
47+
can run the PaddlePaddle container on a remote server and SSH to it
48+
from a laptop.
5349

54-
docker run -d -p 2202:22 paddledev/paddle:cpu-latest
5550

56-
Then we can login to the container using username :code:`root` and password :code:`root`:
51+
Above methods work with the GPU image too -- just please don't forget
52+
to install CUDA driver and let Docker knows about it:
5753

5854
.. code-block:: bash
5955
60-
ssh -p 2202 root@localhost
56+
export CUDA_SO="$(\ls /usr/lib64/libcuda* | xargs -I{} echo '-v {}:{}') $(\ls /usr/lib64/libnvidia* | xargs -I{} echo '-v {}:{}')"
57+
export DEVICES=$(\ls /dev/nvidia* | xargs -I{} echo '--device {}:{}')
58+
docker run ${CUDA_SO} ${DEVICES} -it paddledev/paddle:gpu-latest
6159
6260
63-
Build Docker images
64-
-------------------
61+
Non-AVX Images
62+
--------------
6563

66-
Developers might want to build Docker images from their local commit or from a tagged version. Suppose that your local repo is at :code:`~/work/Paddle`, the following steps builds a cpu variant from your current work:
64+
Please be aware that the CPU-only and the GPU images both use the AVX
65+
instruction set, but old computers produced before 2008 do not support
66+
AVX. The following command checks if your Linux computer supports
67+
AVX:
6768

6869
.. code-block:: bash
6970
70-
cd ~/Paddle
71-
./paddle/scripts/docker/generates.sh # Use m4 to generate Dockerfiles for each variant.
72-
docker build -t paddle:latest -f ./paddle/scripts/docker/Dockerfile.cpu
71+
if cat /proc/cpuinfo | grep -i avx; then echo Yes; else echo No; fi
72+
7373
74-
As a release engineer, you might want to build Docker images for a certain version and publish them to dockerhub.com. You can do this by switching to the right Git tag, or create a new tag, before running `docker build`. For example, the following commands build Docker images for v0.9.0:
74+
If it doesn't, we will need to build non-AVX images manually from
75+
source code:
7576

7677
.. code-block:: bash
7778
78-
cd ~/Paddle
79-
git checkout tags/v0.9.0
80-
./paddle/scripts/docker/generates.sh # Use m4 to generate Dockerfiles for each variant.
81-
docker build -t paddle:cpu-v0.9.0 -f ./paddle/scripts/docker/Dockerfile.cpu
79+
cd ~
80+
git clone github.com/PaddlePaddle/Paddle
81+
cd Paddle
82+
docker build --build-arg WITH_AVX=OFF -t paddle:cpu-noavx -f paddle/scripts/docker/Dockerfile .
83+
docker build --build-arg WITH_AVX=OFF -t paddle:gpu-noavx -f paddle/scripts/docker/Dockerfile.gpu .

0 commit comments

Comments
 (0)