Skip to content

Instantly share code, notes, and snippets.

@tuxedocat
Created December 21, 2017 06:05
Show Gist options
  • Save tuxedocat/7a888ca99afd136de12f05ac4d0680b8 to your computer and use it in GitHub Desktop.
Save tuxedocat/7a888ca99afd136de12f05ac4d0680b8 to your computer and use it in GitHub Desktop.
nvidia-docker2 + (PyTorch on Cuda9.0, cuDNN7)
ARG cuda_version=9.0
ARG cudnn_version=7
ARG distribution=ubuntu16.04
FROM nvidia/cuda:${cuda_version}-cudnn${cudnn_version}-devel-${distribution}
RUN apt-get update && apt-get install -y \
wget \
git \
libhdf5-dev \
g++ \
graphviz \
openmpi-bin && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Conda
ARG miniconda_ver=4.3.30
ARG miniconda_md5=0b80a152332a4ce5250f3c09589c7a81
ENV CONDA_DIR /opt/conda
ENV PATH=$CONDA_DIR/bin:$PATH
RUN mkdir -p $CONDA_DIR && \
echo export PATH=$CONDA_DIR/bin:'$PATH' > /etc/profile.d/conda.sh && \
wget --quiet https://repo.continuum.io/miniconda/Miniconda3-${miniconda_ver}-Linux-x86_64.sh && \
echo "${miniconda_md5} *Miniconda3-${miniconda_ver}-Linux-x86_64.sh" | md5sum -c - && \
/bin/bash /Miniconda3-${miniconda_ver}-Linux-x86_64.sh -f -b -p $CONDA_DIR && \
rm Miniconda3-${miniconda_ver}-Linux-x86_64.sh
ENV NB_USER ml
ENV NB_UID 1000
RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER && \
mkdir -p $CONDA_DIR && \
chown $NB_USER $CONDA_DIR -R && \
mkdir -p /work && \
chown $NB_USER /work
USER ml
ARG python_version=3.6
RUN conda install -y python=${python_version} && \
pip install --upgrade pip && \
pip install http://download.pytorch.org/whl/cu90/torch-0.3.0.post4-cp36-cp36m-linux_x86_64.whl && \
pip install torchvision
RUN conda install \
Pillow \
scikit-learn \
notebook \
pandas \
matplotlib \
mkl \
nose \
pyyaml \
six \
h5py && \
pip install sklearn_pandas && \
conda clean -yt
RUN git clone https://github.com/pytorch/examples /work/examples
ENV PYTHONPATH='/work/:$PYTHONPATH'
WORKDIR /work
EXPOSE 8888
CMD jupyter notebook --port=8888 --ip=0.0.0.0
help:
@cat Makefile
NAME=pytorch
DATA?="${HOME}/container-shared"
GPU?=0
DOCKER_FILE=Dockerfile
DOCKER=GPU=$(GPU) docker
NVRUNTIME=--runtime=nvidia
SRC?=$(shell dirname `pwd`)
build:
docker build \
-t $(NAME):latest \
--build-arg https_proxy=$$HTTP_PROXY --build-arg http_proxy=$$HTTP_PROXY \
--build-arg HTTP_PROXY=$$HTTP_PROXY --build-arg HTTPS_PROXY=$$HTTP_PROXY \
--build-arg NO_PROXY=$$NO_PROXY --build-arg no_proxy=$$NO_PROXY \
-f $(DOCKER_FILE) .
bash:
$(DOCKER) run $(NVRUNTIME) -it \
-v $(SRC):/work/workspace -v $(DATA):/data \
-v /etc/localtime:/etc/localtime:ro \
--env http_proxy=$$HTTP_PROXY \
--env https_proxy=$$HTTPS_PROXY \
--env no_proxy=$$NO_PROXY \
--env HTTP_PROXY=$$HTTP_PROXY \
--env HTTPS_PROXY=$$HTTPS_PROXY \
--env NO_PROXY=$$NO_PROXY \
$(NAME) bash
ipython:
$(DOCKER) run $(NVRUNTIME) -it \
-v $(SRC):/work/workspace -v $(DATA):/data \
-v /etc/localtime:/etc/localtime:ro \
--env http_proxy=$$HTTP_PROXY \
--env https_proxy=$$HTTPS_PROXY \
--env no_proxy=$$NO_PROXY \
--env HTTP_PROXY=$$HTTP_PROXY \
--env HTTPS_PROXY=$$HTTPS_PROXY \
--env NO_PROXY=$$NO_PROXY \
$(NAME) ipython
notebook:
$(DOCKER) run $(NVRUNTIME) -it \
-v $(SRC):/work/workspace -v $(DATA):/data --net=host \
-v /etc/localtime:/etc/localtime:ro \
--env http_proxy=$$HTTP_PROXY \
--env https_proxy=$$HTTPS_PROXY \
--env no_proxy=$$NO_PROXY \
--env HTTP_PROXY=$$HTTP_PROXY \
--env HTTPS_PROXY=$$HTTPS_PROXY \
--env NO_PROXY=$$NO_PROXY \
$(NAME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment