docker_install.rst 3.1 KB
Newer Older
Y
Yi Wang 已提交
1 2
Using and Building Docker Images
================================
3

Y
Yi Wang 已提交
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.
5

Y
Yi Wang 已提交
6 7
Run Docker images
-----------------
8

Y
Yi Wang 已提交
9
For each version of PaddlePaddle, we release 4 variants of Docker images:
10

Y
Yi Wang 已提交
11 12 13 14 15 16 17 18 19 20 21
+-----------------+-------------+-------+
|                 |   CPU AVX   |  GPU  |
+=================+=============+=======+
|       cpu       |   yes       |  no   |
+-----------------+-------------+-------+
|    cpu-noavx    |   no        |  no   |
+-----------------+-------------+-------+
|       gpu       |   yes       |  yes  |
+-----------------+-------------+-------+
|    gpu-noavx    |   no        |  yes  |
+-----------------+-------------+-------+
22

Y
Yi Wang 已提交
23
We run the following command on Linux to check if the CPU supports :code:`AVX`.
24

Y
Yi Wang 已提交
25
.. code-block:: bash
Y
Yi Wang 已提交
26

Y
Yi Wang 已提交
27 28 29 30 31 32 33
   if cat /proc/cpuinfo | grep -i avx; then echo Yes; else echo No; fi

On Mac OS X, we need to run

.. code-block:: bash

   sysctl -a | grep machdep.cpu.leaf7_features
34 35


Y
Yi Wang 已提交
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:
37

Y
Yi Wang 已提交
38
.. code-block:: bash
39

Y
Yi Wang 已提交
40
    docker run -it --rm paddledev/paddle:cpu-latest /bin/bash
41

Y
Yi Wang 已提交
42
To run a GPU-enabled image, you need to install CUDA and let Docker knows about it:
43

Y
Yi Wang 已提交
44
.. code-block:: bash
45

46
    export CUDA_SO="$(\ls /usr/lib64/libcuda* | xargs -I{} echo '-v {}:{}') $(\ls /usr/lib64/libnvidia* | xargs -I{} echo '-v {}:{}')"
47 48 49
    export DEVICES=$(\ls /dev/nvidia* | xargs -I{} echo '--device {}:{}')
    docker run ${CUDA_SO} ${DEVICES} -it paddledev/paddle:gpu-latest

Y
Yi Wang 已提交
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:
51

Y
Yi Wang 已提交
52
.. code-block:: bash
53

Y
Yi Wang 已提交
54
    docker run -d -p 2202:22 paddledev/paddle:cpu-latest
55

Y
Yi Wang 已提交
56
Then we can login to the container using username :code:`root` and password :code:`root`:
57

Y
Yi Wang 已提交
58
.. code-block:: bash
59

Y
Yi Wang 已提交
60
    ssh -p 2202 root@localhost
61 62


Y
Yi Wang 已提交
63 64
Build Docker images
-------------------
65

Y
Yi Wang 已提交
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:
67

Y
Yi Wang 已提交
68
.. code-block:: bash
69

Y
Yi Wang 已提交
70 71 72
  cd ~/Paddle
  ./paddle/scripts/docker/generates.sh # Use m4 to generate Dockerfiles for each variant.
  docker build -t paddle:latest -f ./paddle/scripts/docker/Dockerfile.cpu
73

Y
Yi Wang 已提交
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:
75

Y
Yi Wang 已提交
76
.. code-block:: bash
77

Y
Yi Wang 已提交
78 79 80 81
   cd ~/Paddle
   git checkout tags/v0.9.0
   ./paddle/scripts/docker/generates.sh # Use m4 to generate Dockerfiles for each variant.
   docker build -t paddle:cpu-v0.9.0 -f ./paddle/scripts/docker/Dockerfile.cpu