《动手学深度学习》docker部署

Dockerfiles

FROM nvidia/cuda:9.0-cudnn7-devel
#更换国内节点
ENV MXNET_GLUON_REPO https://apache-mxnet.s3.cn-north-1.amazonaws.com.cn/
RUN echo "" > /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial main" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial universe" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security main" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe" >> /etc/apt/sources.list

RUN cp /etc/apt/sources.list.d/cuda.list /etc/apt/sources.list.d/cuda.list.bak
RUN echo "" > /etc/apt/sources.list.d/cuda.list
# Install CUDA repository for ubuntu
#RUN echo "" > /etc/apt/sources.list.d/cuda.list
#RUN apt-get clean && apt-get update &&  apt-get install -y curl wget
#RUN mv -f /etc/apt/sources.list.d/cuda.list.bak /etc/apt/sources.list.d/cuda.list
#RUN wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub | apt-key add -

RUN apt-get clean && apt-get update &&  apt-get -y upgrade && \
    apt-get install -y wget  curl unzip python3-dev gcc libopencv-dev python-opencv && \
    wget https://bootstrap.pypa.io/get-pip.py && \
    python3 get-pip.py

RUN pip3 install mxnet-cu90==1.5 d2lzh==0.8.11 jupyter==1.0.0 matplotlib==2.2.2 pandas==0.23.4 -i https://mirrors.aliyun.com/pypi/simple/
RUN mkdir d2l-zh && cd d2l-zh
COPY ./d2l-zh.zip /d2l-zh/
WORKDIR /d2l-zh
RUN unzip d2l-zh.zip && rm d2l-zh.zip
RUN jupyter notebook --generate-config
RUN echo "c.NotebookApp.ip='*'" >> ~/.jupyter/jupyter_notebook_config.py && \
echo "c.NotebookApp.open_browser = False" >> ~/.jupyter/jupyter_notebook_config.py && \
#登录密码,from notebook.auth import passwd  passwd() 生成
echo "c.NotebookApp.password = u'sha1:d40fb9f3a0b8:57f92412f4455a6e7fff2cac3dfd05d3d955e425'" >> ~/.jupyter/jupyter_notebook_config.py && \
echo "c.NotebookApp.port = 8888" >> ~/.jupyter/jupyter_notebook_config.py
EXPOSE 8888

CMD [ "jupyter","notebook","--allow-root"]

创建镜像

sudo nvidia-docker build -t nine/gluon_ml:v1 .

启动容器

sudo nvidia-docker run  --name gluon_learn -p 9999:8888 nine/gluon_ml:v1