From 3c2ecc6b15d3deeabd5905849d242bbee2264eee Mon Sep 17 00:00:00 2001 From: ngimel Date: Wed, 25 Jan 2017 14:30:29 -0800 Subject: [PATCH] add dockerfiles (#583) * add dockerfiles --- Dockerfile | 33 +++++++++++++++++++++++++++++++ README.md | 20 +++++++++++++++++++ tools/docker/Dockerfile-v6 | 40 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 Dockerfile create mode 100644 tools/docker/Dockerfile-v6 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000..1a89da20e2ba3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM nvidia/cuda:8.0-cudnn5-devel-ubuntu14.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + git \ + curl \ + ca-certificates \ + libjpeg-dev \ + libpng-dev &&\ + rm -rf /var/lib/apt/lists/* + +RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh && \ + chmod +x ~/miniconda.sh && \ + ~/miniconda.sh -b -p /opt/conda && \ + rm ~/miniconda.sh && \ + /opt/conda/bin/conda install conda-build && \ + /opt/conda/bin/conda create -y --name pytorch-py35 python=3.5.2 numpy scipy ipython mkl&& \ + /opt/conda/bin/conda clean -ya +ENV PATH /opt/conda/envs/pytorch-py35/bin:$PATH +RUN conda install --name pytorch-py35 -c soumith magma-cuda80 +# This must be done before pip so that requirements.txt is available +WORKDIR /opt/pytorch +COPY . . + +RUN cat requirements.txt | xargs -n1 pip install --no-cache-dir && \ + TORCH_CUDA_ARCH_LIST="3.5 5.2 6.0 6.1+PTX" TORCH_NVCC_FLAGS="-Xfatbin -compress-all" \ + CMAKE_LIBRARY_PATH=/opt/conda/envs/pytorch-py35/lib \ + CMAKE_INCLUDE_PATH=/opt/conda/envs/pytorch-py35/include \ + pip install -v . + +WORKDIR /workspace +RUN chmod -R a+w /workspace diff --git a/README.md b/README.md index 2249f2e255dc6..4838aa815bd0b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ We are in an early-release Beta. Expect some adventures and rough edges. - [Installation](#installation) - [Binaries](#binaries) - [From source](#from-source) + - [Docker image](#docker-image) - [Getting Started](#getting-started) - [Communication](#communication) - [Releases and Contributing](#releases-and-contributing) @@ -169,6 +170,25 @@ pip install -r requirements.txt python setup.py install ``` +### Docker image + +Dockerfiles are supplied to build images with cuda support and cudnn v5 and cudnn v6 RC. Build them as usual +``` +docker build . -t pytorch-cudnnv5 +``` +or +``` +docker build . -t pytorch-cudnnv6 -f tools/docker/Dockerfile-v6 +``` +and run them with nvidia-docker: +``` +nvidia-docker run --rm -ti --ipc=host pytorch-cudnnv5 +``` +Please note that pytorch uses shared memory to share data between processes, so if torch multiprocessing is used (e.g. +for multithreaded data loaders) the default shared memory segment size that container runs with is not enough, and you +should increase shared memory size either with --ipc=host or --shm-size command line options to nvidia-docker run. + + ## Getting Started Three pointers to get you started: diff --git a/tools/docker/Dockerfile-v6 b/tools/docker/Dockerfile-v6 new file mode 100644 index 0000000000000..4f0b2bea9d433 --- /dev/null +++ b/tools/docker/Dockerfile-v6 @@ -0,0 +1,40 @@ +FROM nvidia/cuda:8.0-devel-ubuntu14.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + git \ + curl \ + ca-certificates \ + libjpeg-dev \ + libpng-dev &&\ + rm -rf /var/lib/apt/lists/* + + +RUN curl -fsSL http://developer.download.nvidia.com/compute/redist/cudnn/v6.0/cudnn-8.0-linux-x64-v6.0-rc.tgz -O && \ +tar -xzf cudnn-8.0-linux-x64-v6.0-rc.tgz -C /usr/local && \ + rm cudnn-8.0-linux-x64-v6.0-rc.tgz && \ + ldconfig +RUN ln -s /usr/local/cuda/lib64/libcudnn.so.6.0.5 /usr/lib/x86_64-linux-gnu/libcudnn.so.6.0.5 + +RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh && \ + chmod +x ~/miniconda.sh && \ + ~/miniconda.sh -b -p /opt/conda && \ + rm ~/miniconda.sh && \ + /opt/conda/bin/conda install conda-build && \ + /opt/conda/bin/conda create -y --name pytorch-py35 python=3.5.2 numpy scipy ipython mkl&& \ + /opt/conda/bin/conda clean -ya +ENV PATH /opt/conda/envs/pytorch-py35/bin:$PATH +RUN conda install --name pytorch-py35 -c soumith magma-cuda80 +# This must be done before pip so that requirements.txt is available +WORKDIR /opt/pytorch +COPY . . + +RUN cat requirements.txt | xargs -n1 pip install --no-cache-dir && \ + TORCH_CUDA_ARCH_LIST="3.5 5.2 6.0 6.1+PTX" TORCH_NVCC_FLAGS="-Xfatbin -compress-all" \ + CMAKE_LIBRARY_PATH=/opt/conda/envs/pytorch-py35/lib \ + CMAKE_INCLUDE_PATH=/opt/conda/envs/pytorch-py35/include \ + pip install -v . + +WORKDIR /workspace +RUN chmod -R a+w /workspace