问题形容:

当应用Dockerfile从蕴含cuda的镜像建设新的image的时候,显示以下bug:

Step 7/8 : RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y -q     libcudnn6=$CUDNN_VERSION-1+cuda8.0     libcudnn6-dev=$CUDNN_VERSION-1+cuda8.0  && rm -rf /var/lib/apt/lists/* ---> Running in 94b890e74e5aGet:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]Ign:2 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  InReleaseGet:3 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]Ign:4 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64  InReleaseGet:5 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Release [564 B]Get:6 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64  Release [564 B]Get:7 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Release.gpg [801 B]Get:8 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [73.2 kB]Get:9 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64  Release.gpg [801 B]Get:10 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Packages [98.4 kB]Get:11 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [589 kB]Get:12 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64  Packages [17.9 kB]Err:12 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64  Packages  Hash Sum mismatchGet:13 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]Get:14 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]Get:15 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9,802 kB]Get:16 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB]Get:17 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [406 kB]Get:18 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3,486 B]Get:19 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1,558 kB]Get:20 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]Get:21 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9,827 kB]Get:22 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [242 kB]Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [957 kB]Get:25 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.1 kB]Get:26 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [766 kB]Get:27 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [18.5 kB]Get:28 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [5,153 B]Get:29 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [7,705 B]Fetched 25.1 MB in 9s (2,576 kB/s)Reading package lists...E: Failed to fetch http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/Packages.gz  Hash Sum mismatchE: Some index files failed to download. They have been ignored, or old ones used instead.

解决方案

在Dockerfile 运行这行代码

 RUN apt-get -qq -y update && \    DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \    gcc \    ... \

之前退出以下代码

 RUN rm /etc/apt/sources.list.d/cuda.list && rm /etc/apt/sources.list.d/nvidia-ml.list

胜利解决!