docker_install_en.rst 4.2 KB
Newer Older
Y
Yi Wang 已提交
1 2
PaddlePaddle in Docker Containers
=================================
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

T
typhoonzero 已提交
19
Run the following command to download the latest Docker images:
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

T
typhoonzero 已提交
29
     docker pull docker.paddlepaddle.org/paddle
30

T
typhoonzero 已提交
31
Download GPU version images:
H
Helin Wang 已提交
32 33

  .. code-block:: bash
T
typhoonzero 已提交
34 35
     docker pull paddlepaddle/paddle:latest-gpu
     docker pull docker.paddlepaddle.org/paddle:latest-gpu
H
Helin Wang 已提交
36

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

T
typhoonzero 已提交
41 42 43 44
  .. code-block:: bash
     docker pull paddlepaddle/paddle:[tag]
     # i.e.
     docker pull docker.paddlepaddle.org/paddle:0.10.0-gpu
45

T
typhoonzero 已提交
46
.. _docker_run:
王益 已提交
47

T
typhoonzero 已提交
48 49
Launch your training program in Docker
------------------------------
50

T
typhoonzero 已提交
51 52 53 54
Assume that you have already written a PaddlePaddle program
named :code:`train.py` (refer to 
`PaddlePaddleBook <http://www.paddlepaddle.org/docs/develop/book/01.fit_a_line/index.cn.html>`_
for more samples), then run the following command:
55

T
typhoonzero 已提交
56 57
  .. code-block:: bash
     docker run -it -v $PWD:/work paddlepaddle/paddle /work/train.py
58

T
typhoonzero 已提交
59 60 61 62 63
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.
王益 已提交
64

T
typhoonzero 已提交
65 66
Also, you can go into the container shell, run or debug your code
interactively:
王益 已提交
67

T
typhoonzero 已提交
68 69 70 71
  .. code-block:: bash
     docker run -it -v $PWD:/work paddlepaddle/paddle /bin/bash
     cd /work
     python train.py
72

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

T
typhoonzero 已提交
75
.. _docker_run_book:
76

H
Helin Wang 已提交
77 78
PaddlePaddle Book
------------------
79

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

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

H
Helin Wang 已提交
87
.. code-block:: bash
王益 已提交
88

H
Helin Wang 已提交
89
    docker run -p 8888:8888 paddlepaddle/book
王益 已提交
90

H
Helin Wang 已提交
91 92 93 94 95 96 97
Then, you would back and paste the address into the local browser:

.. code-block:: text

    http://localhost:8888/

That's all. Enjoy your journey!
98

T
typhoonzero 已提交
99
.. _docker_run_gpu:
100

T
typhoonzero 已提交
101 102
Train with Docker with GPU
------------------------------
103

T
typhoonzero 已提交
104 105 106 107
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.
108

T
typhoonzero 已提交
109 110 111 112 113
.. code-block:: bash

  nvidia-docker run -it -v $PWD:/work paddledev/paddle:latest-gpu /bin/bash

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

.. code-block:: bash

T
typhoonzero 已提交
117 118 119 120 121
  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:latest-gpu

About AVX:
122

T
typhoonzero 已提交
123 124 125 126
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
`build <./build_from_source_en.rst>`_ with :code:`WITH_AVX=OFF`.
127

T
typhoonzero 已提交
128 129 130 131 132
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