docker_install_en.rst 4.7 KB
Newer Older
武毅 已提交
1
Run in Docker Containers
Y
Yi Wang 已提交
2
=================================
3

T
typhoonzero 已提交
4 5 6
Run PaddlePaddle in Docker container so that you don't need to care about
runtime dependencies, also you can run under Windows system. You can get
tutorials at `here <https://docs.docker.com/get-started/>`_ .
7

T
typhoonzero 已提交
8 9 10
If you are using Windows, please refer to
`this <https://docs.docker.com/toolbox/toolbox_install_windows/>`_
tutorial to start running docker under windows.
H
Helin Wang 已提交
11

T
typhoonzero 已提交
12
After you've read above tutorials you may proceed the following steps.
H
Helin Wang 已提交
13

T
typhoonzero 已提交
14
.. _docker_pull:
H
Helin Wang 已提交
15

T
typhoonzero 已提交
16 17
Pull PaddlePaddle Docker Image
------------------------------
H
Helin Wang 已提交
18

L
Luo Tao 已提交
19
Run the following command to download the latest Docker images, the version is cpu_avx_mkl:
H
Helin Wang 已提交
20 21 22

  .. code-block:: bash

T
typhoonzero 已提交
23
     docker pull paddlepaddle/paddle
H
Helin Wang 已提交
24

T
typhoonzero 已提交
25
For users in China, we provide a faster mirror:
26 27 28

  .. code-block:: bash

Y
Yancey 已提交
29
     docker pull docker.paddlepaddlehub.com/paddle
30

L
Luo Tao 已提交
31
Download GPU version (cuda8.0_cudnn5_avx_mkl) images:
H
Helin Wang 已提交
32 33

  .. code-block:: bash
T
typhoonzero 已提交
34

T
typhoonzero 已提交
35
     docker pull paddlepaddle/paddle:latest-gpu
Y
Yancey 已提交
36
     docker pull docker.paddlepaddlehub.com/paddle:latest-gpu
H
Helin Wang 已提交
37

T
typhoonzero 已提交
38 39 40 41 42 43 44 45 46 47
Choose between different BLAS version:

  .. code-block:: bash

     # image using MKL by default
     docker pull paddlepaddle/paddle
     # image using OpenBLAS
     docker pull paddlepaddle/paddle:latest-openblas


T
typhoonzero 已提交
48 49 50
If you want to use legacy versions, choose a tag from
`DockerHub <https://hub.docker.com/r/paddlepaddle/paddle/tags/>`_
and run:
51

T
typhoonzero 已提交
52
  .. code-block:: bash
T
typhoonzero 已提交
53

T
typhoonzero 已提交
54 55
     docker pull paddlepaddle/paddle:[tag]
     # i.e.
Y
Yancey 已提交
56
     docker pull docker.paddlepaddlehub.com/paddle:0.11.0-gpu
57

T
typhoonzero 已提交
58
.. _docker_run:
王益 已提交
59

T
typhoonzero 已提交
60
Launch your training program in Docker
L
Luo Tao 已提交
61
--------------------------------------
62

T
typhoonzero 已提交
63
Assume that you have already written a PaddlePaddle program
T
typhoonzero 已提交
64
named :code:`train.py` under directory :code:`/home/work` (refer to 
T
typhoonzero 已提交
65
`PaddlePaddleBook <http://www.paddlepaddle.org/docs/develop/book/01.fit_a_line/index.cn.html>`_ 
T
typhoonzero 已提交
66
for more samples), then run the following command:
67

T
typhoonzero 已提交
68
  .. code-block:: bash
T
typhoonzero 已提交
69 70

     cd /home/work
T
typhoonzero 已提交
71
     docker run -it -v $PWD:/work paddlepaddle/paddle /work/train.py
72

T
typhoonzero 已提交
73 74 75 76 77
In the above command, :code:`-it` means run the container interactively;
:code:`-v $PWD:/work` means mount the current directory ($PWD will expand
to current absolute path in Linux) under :code:`/work` in the container.
:code:`paddlepaddle/paddle` to specify image to use; finnally
:code:`/work/train.py` is the command to run inside docker.
王益 已提交
78

T
typhoonzero 已提交
79 80
Also, you can go into the container shell, run or debug your code
interactively:
王益 已提交
81

T
typhoonzero 已提交
82 83 84 85
  .. code-block:: bash
     docker run -it -v $PWD:/work paddlepaddle/paddle /bin/bash
     cd /work
     python train.py
86

T
typhoonzero 已提交
87
**NOTE: We did not install vim in the default docker image to reduce the image size, you can run** :code:`apt-get install -y vim` **to install it if you need to edit python files.**
王益 已提交
88

T
typhoonzero 已提交
89
.. _docker_run_book:
90

H
Helin Wang 已提交
91 92
PaddlePaddle Book
------------------
93

T
typhoonzero 已提交
94
You can create a container serving PaddlePaddle Book using Jupyter Notebook in
T
typhoonzero 已提交
95 96
one minute using Docker. PaddlePaddle Book is an interactive Jupyter Notebook
for users and developers.If you want to
H
Helin Wang 已提交
97
dig deeper into deep learning, PaddlePaddle Book definitely is your best choice.
王益 已提交
98

H
Helin Wang 已提交
99
We provide a packaged book image, simply issue the command:
100

T
typhoonzero 已提交
101
  .. code-block:: bash
王益 已提交
102

T
typhoonzero 已提交
103
     docker run -p 8888:8888 paddlepaddle/book
王益 已提交
104

105 106 107 108 109 110
For users in China, we provide a faster mirror:

  .. code-block: bash

    docker run -p 8888:8888 docker.paddlepaddlehub.com/book

H
Helin Wang 已提交
111 112
Then, you would back and paste the address into the local browser:

T
typhoonzero 已提交
113
  .. code-block:: text
H
Helin Wang 已提交
114

T
typhoonzero 已提交
115
     http://localhost:8888/
H
Helin Wang 已提交
116 117

That's all. Enjoy your journey!
118

T
typhoonzero 已提交
119
.. _docker_run_gpu:
120

T
typhoonzero 已提交
121 122
Train with Docker with GPU
------------------------------
123

T
typhoonzero 已提交
124 125 126 127
We recommend using
`nvidia-docker <https://github.com/NVIDIA/nvidia-docker>`_
to run GPU training jobs. Please ensure you have latest
GPU driver installed before move on.
128

T
typhoonzero 已提交
129
  .. code-block:: bash
T
typhoonzero 已提交
130

L
Luo Tao 已提交
131
     nvidia-docker run -it -v $PWD:/work paddlepaddle/paddle:latest-gpu /bin/bash
T
typhoonzero 已提交
132 133

**NOTE: If you don't have nvidia-docker installed, try the following method to mount CUDA libs and devices into the container.**
134

T
typhoonzero 已提交
135
  .. code-block:: bash
136

T
typhoonzero 已提交
137 138
     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 {}:{}')
L
Luo Tao 已提交
139
     docker run ${CUDA_SO} ${DEVICES} -it paddlepaddle/paddle:latest-gpu
T
typhoonzero 已提交
140

T
typhoonzero 已提交
141
**About AVX:**
142

T
typhoonzero 已提交
143 144 145
AVX is a kind of CPU instruction can accelerate PaddlePaddle's calculations.
The latest PaddlePaddle Docker image turns AVX on by default, so, if your
computer doesn't support AVX, you'll probably need to
L
Luo Tao 已提交
146
`build <./build_from_source_en.html>`_ with :code:`WITH_AVX=OFF`.
147

T
typhoonzero 已提交
148 149 150 151 152
The following command will tell you whether your computer supports AVX.

   .. code-block:: bash

      if cat /proc/cpuinfo | grep -i avx; then echo Yes; else echo No; fi