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
  .. code-block:: bash
83

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

T
typhoonzero 已提交
88
**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.**
王益 已提交
89

T
typhoonzero 已提交
90
.. _docker_run_book:
91

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

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

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

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

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

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

  .. code-block: bash

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

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

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

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

That's all. Enjoy your journey!
119

T
typhoonzero 已提交
120
.. _docker_run_gpu:
121

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

T
typhoonzero 已提交
125 126 127 128
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.
129

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

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

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

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

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

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

T
typhoonzero 已提交
144 145 146
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 已提交
147
`build <./build_from_source_en.html>`_ with :code:`WITH_AVX=OFF`.
148

T
typhoonzero 已提交
149 150 151 152 153
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