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

If you are using Windows, please refer to this tutorial to start running docker under windows.

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

## Pull PaddlePaddle Docker Image

Run the following command to download the latest Docker images:

>     docker pull paddlepaddle/paddle

For users in China, we provide a faster mirror:

>     docker pull docker.paddlepaddle.org/paddle

Download GPU version images:

>     docker pull paddlepaddle/paddle:latest-gpu
>     docker pull docker.paddlepaddle.org/paddle:latest-gpu

Choose between different BLAS version:

>     # 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 and run:

>     docker pull paddlepaddle/paddle:[tag]
>     # i.e.
>     docker pull docker.paddlepaddle.org/paddle:0.10.0-gpu

## Launch your training program in Docker

Assume that you have already written a PaddlePaddle program named `train.py` under directory `/home/work` (refer to PaddlePaddleBook for more samples), then run the following command:

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

In the above command, `-it` means run the container interactively; `-v $PWD:/work` means mount the current directory ($PWD will expand to current absolute path in Linux) under `/work` in the container. `paddlepaddle/paddle` to specify image to use; finnally `/work/train.py` is the command to run inside docker.

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

NOTE: We did not install vim in the default docker image to reduce the image size, you can run `apt-get install -y vim` to install it if you need to edit python files.

## 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:

>     docker run -p 8888:8888 paddlepaddle/book

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

>     http://localhost:8888/

That’s all. Enjoy your journey!

## Train with Docker with GPU

We recommend using nvidia-docker to run GPU training jobs. Please ensure you have latest GPU driver installed before move on.

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

>     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:

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 with `WITH_AVX=OFF`.

The following command will tell you whether your computer supports AVX.

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