Skip to content

Commit 3c2ecc6

Browse files
ngimelsoumith
authored andcommitted
add dockerfiles (pytorch#583)
* add dockerfiles
1 parent aa46055 commit 3c2ecc6

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM nvidia/cuda:8.0-cudnn5-devel-ubuntu14.04
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
build-essential \
5+
cmake \
6+
git \
7+
curl \
8+
ca-certificates \
9+
libjpeg-dev \
10+
libpng-dev &&\
11+
rm -rf /var/lib/apt/lists/*
12+
13+
RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh && \
14+
chmod +x ~/miniconda.sh && \
15+
~/miniconda.sh -b -p /opt/conda && \
16+
rm ~/miniconda.sh && \
17+
/opt/conda/bin/conda install conda-build && \
18+
/opt/conda/bin/conda create -y --name pytorch-py35 python=3.5.2 numpy scipy ipython mkl&& \
19+
/opt/conda/bin/conda clean -ya
20+
ENV PATH /opt/conda/envs/pytorch-py35/bin:$PATH
21+
RUN conda install --name pytorch-py35 -c soumith magma-cuda80
22+
# This must be done before pip so that requirements.txt is available
23+
WORKDIR /opt/pytorch
24+
COPY . .
25+
26+
RUN cat requirements.txt | xargs -n1 pip install --no-cache-dir && \
27+
TORCH_CUDA_ARCH_LIST="3.5 5.2 6.0 6.1+PTX" TORCH_NVCC_FLAGS="-Xfatbin -compress-all" \
28+
CMAKE_LIBRARY_PATH=/opt/conda/envs/pytorch-py35/lib \
29+
CMAKE_INCLUDE_PATH=/opt/conda/envs/pytorch-py35/include \
30+
pip install -v .
31+
32+
WORKDIR /workspace
33+
RUN chmod -R a+w /workspace

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ We are in an early-release Beta. Expect some adventures and rough edges.
1414
- [Installation](#installation)
1515
- [Binaries](#binaries)
1616
- [From source](#from-source)
17+
- [Docker image](#docker-image)
1718
- [Getting Started](#getting-started)
1819
- [Communication](#communication)
1920
- [Releases and Contributing](#releases-and-contributing)
@@ -169,6 +170,25 @@ pip install -r requirements.txt
169170
python setup.py install
170171
```
171172

173+
### Docker image
174+
175+
Dockerfiles are supplied to build images with cuda support and cudnn v5 and cudnn v6 RC. Build them as usual
176+
```
177+
docker build . -t pytorch-cudnnv5
178+
```
179+
or
180+
```
181+
docker build . -t pytorch-cudnnv6 -f tools/docker/Dockerfile-v6
182+
```
183+
and run them with nvidia-docker:
184+
```
185+
nvidia-docker run --rm -ti --ipc=host pytorch-cudnnv5
186+
```
187+
Please note that pytorch uses shared memory to share data between processes, so if torch multiprocessing is used (e.g.
188+
for multithreaded data loaders) the default shared memory segment size that container runs with is not enough, and you
189+
should increase shared memory size either with --ipc=host or --shm-size command line options to nvidia-docker run.
190+
191+
172192
## Getting Started
173193

174194
Three pointers to get you started:

tools/docker/Dockerfile-v6

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM nvidia/cuda:8.0-devel-ubuntu14.04
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
build-essential \
5+
cmake \
6+
git \
7+
curl \
8+
ca-certificates \
9+
libjpeg-dev \
10+
libpng-dev &&\
11+
rm -rf /var/lib/apt/lists/*
12+
13+
14+
RUN curl -fsSL http://developer.download.nvidia.com/compute/redist/cudnn/v6.0/cudnn-8.0-linux-x64-v6.0-rc.tgz -O && \
15+
tar -xzf cudnn-8.0-linux-x64-v6.0-rc.tgz -C /usr/local && \
16+
rm cudnn-8.0-linux-x64-v6.0-rc.tgz && \
17+
ldconfig
18+
RUN ln -s /usr/local/cuda/lib64/libcudnn.so.6.0.5 /usr/lib/x86_64-linux-gnu/libcudnn.so.6.0.5
19+
20+
RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh && \
21+
chmod +x ~/miniconda.sh && \
22+
~/miniconda.sh -b -p /opt/conda && \
23+
rm ~/miniconda.sh && \
24+
/opt/conda/bin/conda install conda-build && \
25+
/opt/conda/bin/conda create -y --name pytorch-py35 python=3.5.2 numpy scipy ipython mkl&& \
26+
/opt/conda/bin/conda clean -ya
27+
ENV PATH /opt/conda/envs/pytorch-py35/bin:$PATH
28+
RUN conda install --name pytorch-py35 -c soumith magma-cuda80
29+
# This must be done before pip so that requirements.txt is available
30+
WORKDIR /opt/pytorch
31+
COPY . .
32+
33+
RUN cat requirements.txt | xargs -n1 pip install --no-cache-dir && \
34+
TORCH_CUDA_ARCH_LIST="3.5 5.2 6.0 6.1+PTX" TORCH_NVCC_FLAGS="-Xfatbin -compress-all" \
35+
CMAKE_LIBRARY_PATH=/opt/conda/envs/pytorch-py35/lib \
36+
CMAKE_INCLUDE_PATH=/opt/conda/envs/pytorch-py35/include \
37+
pip install -v .
38+
39+
WORKDIR /workspace
40+
RUN chmod -R a+w /workspace

0 commit comments

Comments
 (0)