docker_install.rst 3.3 KB
Newer Older
Y
Yi Wang 已提交
1 2
PaddlePaddle in Docker Containers
=================================
3

Y
Yi Wang 已提交
4 5 6 7 8 9
Docker container is currently the only officially-supported way to
running PaddlePaddle.  This is reasonable as Docker now runs on all
major operating systems including Linux, Mac OS X, and Windows.
Please be aware that you will need to change `Dockers settings
<https://github.com/PaddlePaddle/Paddle/issues/627>`_ to make full use
of your hardware resource on Mac OS X and Windows.
10 11


Y
Yi Wang 已提交
12 13
CPU-only and GPU Images
-----------------------
14

Y
Yi Wang 已提交
15 16 17 18
For each version of PaddlePaddle, we release 2 Docker images, a
CPU-only one and a CUDA GPU one.  We do so by configuring
`dockerhub.com <https://hub.docker.com/r/paddledev/paddle/>`_
automatically runs the following commands:
19

Y
Yi Wang 已提交
20
.. code-block:: base
21

22 23
   docker build -t paddle:cpu -f paddle/scripts/docker/Dockerfile .
   docker build -t paddle:gpu -f paddle/scripts/docker/Dockerfile.gpu .
Y
Yi Wang 已提交
24

Y
Yi Wang 已提交
25

Y
Yi Wang 已提交
26
To run the CPU-only image as an interactive container:
Y
Yi Wang 已提交
27 28 29

.. code-block:: bash

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

Y
Yi Wang 已提交
32
or, we can run it as a daemon container
33

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

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

Y
Yi Wang 已提交
38
and SSH to this container using password :code:`root`:
39

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

Y
Yi Wang 已提交
42
    ssh -p 2202 root@localhost
43

Y
Yi Wang 已提交
44 45 46 47 48
An advantage of using SSH is that we can connect to PaddlePaddle from
more than one terminals.  For example, one terminal running vi and
another one running Python interpreter.  Another advantage is that we
can run the PaddlePaddle container on a remote server and SSH to it
from a laptop.
49 50


Y
Yi Wang 已提交
51 52
Above methods work with the GPU image too -- just please don't forget
to install CUDA driver and let Docker knows about it:
53

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

Y
Yi Wang 已提交
56 57 58
    export CUDA_SO="$(\ls /usr/lib64/libcuda* | xargs -I{} echo '-v {}:{}') $(\ls /usr/lib64/libnvidia* | xargs -I{} echo '-v {}:{}')"
    export DEVICES=$(\ls /dev/nvidia* | xargs -I{} echo '--device {}:{}')
    docker run ${CUDA_SO} ${DEVICES} -it paddledev/paddle:gpu-latest
59 60


Y
Yi Wang 已提交
61 62
Non-AVX Images
--------------
63

Y
Yi Wang 已提交
64 65 66 67
Please be aware that the CPU-only and the GPU images both use the AVX
instruction set, but old computers produced before 2008 do not support
AVX.  The following command checks if your Linux computer supports
AVX:
68

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

Y
Yi Wang 已提交
71 72
   if cat /proc/cpuinfo | grep -i avx; then echo Yes; else echo No; fi

73

Y
Yi Wang 已提交
74 75
If it doesn't, we will need to build non-AVX images manually from
source code:
76

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

Y
Yi Wang 已提交
79 80 81
   cd ~
   git clone github.com/PaddlePaddle/Paddle
   cd Paddle
L
Liu Yiqun 已提交
82
   git submodule update --init --recursive
Y
Yi Wang 已提交
83 84
   docker build --build-arg WITH_AVX=OFF -t paddle:cpu-noavx -f paddle/scripts/docker/Dockerfile .
   docker build --build-arg WITH_AVX=OFF -t paddle:gpu-noavx -f paddle/scripts/docker/Dockerfile.gpu .
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106


Documentation
-------------

Paddle Docker images include an HTML version of C++ source code
generated using `woboq code browser
<https://github.com/woboq/woboq_codebrowser>`_.  This makes it easy
for users to browse and understand the C++ source code.

As long as we give the Paddle Docker container a name, we can run an
additional nginx Docker container to serve the volume from the Paddle
container:

.. code-block:: bash

   docker run -d --name paddle-cpu-doc paddle:cpu
   docker run -d --volumes-from paddle-cpu-doc -p 8088:80 nginx


Then we can direct our Web browser to the HTML version of source code
at http://localhost:8088/paddle/