ubuntu1604-Python35-cuda9-cudnn7-gpu-dockerfile
一,在某目录下有如下文件:
-rw-r--r-- 1 root root 1643293725 9月 2 11:46 cuda_9.0.176_384.81_linux.run
-rw-r--r-- 1 root root 1250 9月 3 17:45 Dockerfile
-rw-r--r-- 1 root root 102521974 9月 2 19:18 libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
-rwxr-xr-x. 1 root root 111258448 8月 21 16:58 NVIDIA-Linux-x86_64-430.40.run
-rw-r--r-- 1 root root 20766931 8月 30 12:15 Python-3.5.5.tgz
-rw-r--r-- 1 root root 720 9月 3 13:55 sources.list
-rw-r--r-- 1 root root 258835666 9月 3 17:17 tensorflow_gpu-1.11.0-cp35-cp35m-linux_x86_64.whl
二 ,该目录下执行构建命令,时间较长,如:
docker build -t "ubuntu1604-python35-nvidia-cuda90-cudnn7-dockerfil" .
三,使用
nvidia-docker run -it --rm --privileged=true -v $PWD:/data ubuntu1604-python35-nvidia-cuda90-cudnn7-dockerfil /bin/bash
不添加--privileged=true 容器无法正常使用nvidia-smi
Dockerfile 默认无入口命令,即起容器没有后接命令会起不来,如没有 /bin/bash
四,操作目录在 192.168.0.154:/gpu/cuda/1604-py3.5-tensor1.11-keras2.2.4
附:
Dockerfile
FROM ubuntu:16.04
MAINTAINER yon
ENV PATH /usr/local/cuda-9.0/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
ADD Python-3.5.5.tgz /opt
ADD sources.list /etc/apt/sources.list
RUN apt-get update && apt-get install -y
#安装依赖
RUN apt-get install gcc -y && apt-get install make -y \
&& apt-get install vim -y && apt-get install openssl -y \
&& apt-get install libssl-dev -y && apt-get install python3-pip -y
RUN ./opt/Python-3.5.5/configure --prefix=/usr/local/python3.5 \
&& make && make install
COPY libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb /
COPY cuda_9.0.176_384.81_linux.run /
COPY NVIDIA-Linux-x86_64-430.40.run /
COPY tensorflow_gpu-1.11.0-cp35-cp35m-linux_x86_64.whl /
RUN apt-get -y -q install gcc kmod \
&& sh NVIDIA-Linux-x86_64-430.40.run -a -N --ui=none --no-kernel-module \
&& sh cuda_9.0.176_384.81_linux.run --no-opengl-libs --toolkit -silent \
&& dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb \
&& pip3 install -i https://mirrors.aliyun.com/pypi/simple/ tensorflow_gpu-1.11.0-cp35-cp35m-linux_x86_64.whl \
&& pip3 install -i https://mirrors.aliyun.com/pypi/simple/ Keras==2.2.4
CMD [""]
------------------------------------------------------------------------------------------------------------------------------------
sources.list
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe