docker_install_en.rst 4.7 KB
Newer Older
J
Jeff Wang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
Run in Docker Containers
=================================

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/>`_ .

If you are using Windows, please refer to
`this <https://docs.docker.com/toolbox/toolbox_install_windows/>`_
tutorial to start running docker under windows.

After you've read above tutorials you may proceed the following steps.

.. _docker_pull:

Pull PaddlePaddle Docker Image
------------------------------

Run the following command to download the latest Docker images, the version is cpu_avx_mkl:

  .. code-block:: bash

     docker pull paddlepaddle/paddle

For users in China, we provide a faster mirror:

  .. code-block:: bash

     docker pull docker.paddlepaddlehub.com/paddle

Download GPU version (cuda8.0_cudnn5_avx_mkl) images:

  .. code-block:: bash

     docker pull paddlepaddle/paddle:latest-gpu
     docker pull docker.paddlepaddlehub.com/paddle:latest-gpu

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


If you want to use legacy versions, choose a tag from
`DockerHub <https://hub.docker.com/r/paddlepaddle/paddle/tags/>`_
and run:

  .. code-block:: bash

     docker pull paddlepaddle/paddle:[tag]
     # i.e.
     docker pull docker.paddlepaddlehub.com/paddle:0.11.0-gpu

.. _docker_run:

Launch your training program in Docker
--------------------------------------

Assume that you have already written a PaddlePaddle program
named :code:`train.py` under directory :code:`/home/work` (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:

  .. code-block:: bash

     cd /home/work
     docker run -it -v $PWD:/work paddlepaddle/paddle /work/train.py

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.

Also, you can go into the container shell, run or debug your code
interactively:

  .. code-block:: bash

     docker run -it -v $PWD:/work paddlepaddle/paddle /bin/bash
     cd /work
     python train.py

**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.**

.. _docker_run_book:

PaddlePaddle Book
------------------

You can create a container serving PaddlePaddle Book using Jupyter Notebook in
one minute using Docker. PaddlePaddle Book is an interactive Jupyter Notebook
for users and developers.If you want to
dig deeper into deep learning, PaddlePaddle Book definitely is your best choice.

We provide a packaged book image, simply issue the command:

  .. code-block:: bash

     docker run -p 8888:8888 paddlepaddle/book

For users in China, we provide a faster mirror:

  .. code-block:: bash

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

Then, you would back and paste the address into the local browser:

  .. code-block:: text

     http://localhost:8888/

That's all. Enjoy your journey!

.. _docker_run_gpu:

Train with Docker with GPU
------------------------------

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.

  .. code-block:: bash

     nvidia-docker run -it -v $PWD:/work paddlepaddle/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.**

  .. code-block:: bash

     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 paddlepaddle/paddle:latest-gpu

**About AVX:**

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.html>`_ with :code:`WITH_AVX=OFF`.

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