码迷,mamicode.com
首页 > 系统相关 > 详细

自定义基于Ubuntu16.04的cuda10 + pytorch1.5基础镜像包

时间:2020-10-22 22:29:37      阅读:49      评论:0      收藏:0      [点我收藏+]

标签:服务   com   ati   fail   version   invalid   自定义   cap   http   

参考官方dockerfile
https://gitlab.com/nvidia/container-images/cuda/-/tree/master/dist/10.2/ubuntu16.04-x86_64

制作基础包base

FROM ubuntu:16.04
LABEL maintainer "NVIDIA CORPORATION <cudatools@nvidia.com>"

# 添加了apt-get update的参数,要求apt服务器传输无缓存文件,防止GPG报错,无法下载deb包
# 此处比官方多添加一个取消认证选项
# 修改nvidia.com 为nvidia.cn
# 修改apt镜像源为中科大
RUN  echo "deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse        deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse        deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse        deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse        deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse        deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse        deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse       deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse        deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse        deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse" | tee /etc/apt/sources.list 
    && apt-get -o Acquire::https::No-Cache=True -o Acquire::http::No-Cache=True update     && apt-get install -y --no-install-recommends  --allow-unauthenticated \ 
    ca-certificates apt-transport-https gnupg-curl &&     NVIDIA_GPGKEY_SUM=d1be581509378368edeec8c1eb2958702feedf3bc3d17011adbf24efacce4ab5 &&     NVIDIA_GPGKEY_FPR=ae09fe4bbd223a84b2ccfce3f60f4b3d7fa2af80 &&     apt-key adv --fetch-keys https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub &&     apt-key adv --export --no-emit-version -a $NVIDIA_GPGKEY_FPR | tail -n +5 > cudasign.pub &&     echo "$NVIDIA_GPGKEY_SUM  cudasign.pub" | sha256sum -c --strict - && rm cudasign.pub &&     echo "deb https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/cuda.list &&     echo "deb https://developer.download.nvidia.cn/compute/machine-learning/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list &&     apt-get purge --auto-remove -y gnupg-curl     && rm -rf /var/lib/apt/lists/*

ENV CUDA_VERSION 10.2.89
ENV CUDA_PKG_VERSION 10-2=$CUDA_VERSION-1

# For libraries in the cuda-compat-* package: https://docs.nvidia.com/cuda/eula/index.html#attachment-a
# 添加了apt-get update的参数,要求apt服务器传输无缓存文件,防止GPG报错,无法下载deb包
# 此处比官方多添加一个取消认证选项
RUN apt-get -o Acquire::https::No-Cache=True -o Acquire::http::No-Cache=True update     && apt-get install -y --no-install-recommends  --allow-unauthenticated \ 
    cuda-cudart-$CUDA_PKG_VERSION     cuda-compat-10-2     && ln -s cuda-10.2 /usr/local/cuda &&     rm -rf /var/lib/apt/lists/*

# Required for nvidia-docker v1
RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf &&     echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf

ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64

# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV NVIDIA_REQUIRE_CUDA "cuda>=10.2 brand=tesla,driver>=396,driver<397 brand=tesla,driver>=410,driver<411 brand=tesla,driver>=418,driver<419 brand=tesla,driver>=440,driver<441"
docker build . -t  cuda10.2:10.2-base-ubuntu16.04    # 此处版本+标签的定义规则与官方dockerfile制作统一,且易于识别tag

基于base包制作runtime包

ARG IMAGE_NAME
FROM ${IMAGE_NAME}:10.2-base-ubuntu16.04

LABEL maintainer "NVIDIA CORPORATION <cudatools@nvidia.com>"

ENV NCCL_VERSION 2.7.8

# 添加了apt-get update的参数,要求apt服务器传输无缓存文件,防止GPG报错,无法下载deb包
# 此处比官方多添加一个取消认证选项
RUN apt-get -o Acquire::https::No-Cache=True -o Acquire::http::No-Cache=True update     && apt-get install -y --no-install-recommends  --allow-unauthenticated \  
    cuda-libraries-$CUDA_PKG_VERSION     cuda-npp-$CUDA_PKG_VERSION     cuda-nvtx-$CUDA_PKG_VERSION     libcublas10=10.2.2.89-1     libnccl2=$NCCL_VERSION-1+cuda10.2     && apt-mark hold libnccl2     && rm -rf /var/lib/apt/lists/*
# 此处需要添加传递给ARG的参数
docker  build . -t cuda10.2:10.2-runtime-ubuntu16.04 --build-arg IMAGE_NAME=cuda10.2;CUDA_PKG_VERSION=10.2.89

基于runtime包制作含cudnn7的包

ARG IMAGE_NAME
FROM ${IMAGE_NAME}:10.2-runtime-ubuntu16.04
LABEL maintainer "NVIDIA CORPORATION <cudatools@nvidia.com>"

ENV CUDNN_VERSION 7.6.5.32

LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}"

# 添加了apt-get update的参数,要求apt服务器传输无缓存文件,防止GPG报错,无法下载deb包
# 此处比官方多添加一个取消认证选项
RUN apt-get -o Acquire::https::No-Cache=True -o Acquire::http::No-Cache=True update       && apt-get install -y --no-install-recommends --allow-unauthenticated     libcudnn7=$CUDNN_VERSION-1+cuda10.2     && apt-mark hold libcudnn7 &&     rm -rf /var/lib/apt/lists/*
# 此处需要添加传递给ARG的参数
docker  build . -t cuda10.2:10.2-runtime-cudnn7-ubuntu16.04 --build-arg IMAGE_NAME=cuda10.2
# 未添加apt-get -o update的参数,会出现的GPG报错
Reading package lists...
W: GPG error: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Release: The following signatures were invalid: BADSIG F60F4B3D7FA2AF80 cudatools <cudatools@nvidia.com>
W: The repository ‘https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Release‘ is not signed.
E: Failed to fetch https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/Packages  Writing more data than expected (1580267 > 1579913)

自定义基于Ubuntu16.04的cuda10 + pytorch1.5基础镜像包

标签:服务   com   ati   fail   version   invalid   自定义   cap   http   

原文地址:https://blog.51cto.com/dldxzjr/2542810

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!