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
The following command line detects if your CPU supports :code:`AVX`.
24 25

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

27 28 29
    if cat /proc/cpuinfo | grep -q avx ; then echo "Support AVX"; else echo "Not support AVX"; fi


Y
Yi Wang 已提交
30
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:
31 32 33

..  code-block:: bash

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

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

..  code-block:: bash

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

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

Y
Yi Wang 已提交
46
..  code-block:: bash
47

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

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

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

Y
Yi Wang 已提交
54
    ssh -p 2202 root@localhost
55 56


Y
Yi Wang 已提交
57 58
Build Docker images
-------------------
59

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

Y
Yi Wang 已提交
62
.. code-block:: bash
63

Y
Yi Wang 已提交
64 65 66
  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
67

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

Y
Yi Wang 已提交
70
.. code-block:: bash
71

Y
Yi Wang 已提交
72 73 74 75
   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