在Ubuntu 16.04上製作 NVIDIA cuDNN Docker image
第七步:使用這些Docker image本文講述了如何在Kde Ubuntu 16.04.03 (LTS發行版)上製作(編譯)NVIDIA cuDNN Docker image文件。
第一步:製作好NVIDIA CUDA Docker image:
參考Gemfield專欄文章:在Ubuntu 16.04上製作 NVIDIA CUDA Docker image
第二步:build NVIDIA cuDNN 運行時的 Docker image:
1,取得Ubuntu版的NVIDIA cuDNN 6.0 runtime版本的Dockerfile:
下載:8.0/runtime/cudnn6/Dockerfile · ubuntu16.04 · nvidia / cuda
然後放置到當前目錄(本步驟沒有使用上面的官方版本,而是使用了下面的版本),這個Dockerfile使用了 「gemfield/ubuntu-runtime-cuda」 作為父 image。
FROM gemfield/ubuntu-runtime-cuda:8.0LABEL maintainer "Gemfield <gemfield@civilnet.cn>"RUN echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.listENV CUDNN_VERSION 6.0.21LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}"RUN apt-get update && apt-get install -y --no-install-recommends libcudnn6=$CUDNN_VERSION-1+cuda8.0 && rm -rf /var/lib/apt/lists/*
2,在包含上面Dockerfile的當前目錄,執行Docker build命令來生成"gemfield/ubuntu-runtime-cudnn:6.0" Docker image:
gemfield@ai:~/AI/dockerfiles/cudnn/runtime$ docker build -t "gemfield/ubuntu-runtime-cudnn:6.0" . Sending build context to Docker daemon 2.048kBStep 1/6 : FROM gemfield/ubuntu-runtime-cuda:8.0 ---> d0b82ef8f4d2Step 2/6 : LABEL maintainer "Gemfield <gemfield@civilnet.cn>" ---> Using cache ---> c103d5ca0de3Step 3/6 : RUN echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list ---> Running in 34d93da88528 ---> d8c2c79a024bRemoving intermediate container 34d93da88528Step 4/6 : ENV CUDNN_VERSION 6.0.21 ---> Running in e16c8fb33d93 ---> 27617abd2787Removing intermediate container e16c8fb33d93Step 5/6 : LABEL com.nvidia.cudnn.version "${CUDNN_VERSION}" ---> Running in 9cddec34fd9f ---> 07a1af4534e4Removing intermediate container 9cddec34fd9fStep 6/6 : RUN apt-get update && apt-get install -y --no-install-recommends libcudnn6=$CUDNN_VERSION-1+cuda8.0 && rm -rf /var/lib/apt/lists/* ---> Running in eaa0a052e3f8Get: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://security.ubuntu.com/ubuntu xenial-security/universe Sources [46.8 kB]Get:8 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 Release.gpg [801 B]Get:9 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [440 kB]Get:10 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Release.gpg [801 B]Get:11 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.8 kB]Get:12 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 Packages [66.0 kB]Get:13 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [204 kB]Get:14 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [2935 B]Get:15 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Packages [8408 B]Get:16 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]Get:17 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]Get:18 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]Get:19 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 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 [9827 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 [214 kB]Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [799 kB]Get:25 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.6 kB]Get:26 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [666 kB]Get:27 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [17.5 kB]Get:28 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [5177 B]Get:29 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [6236 B]Fetched 24.4 MB in 49s (497 kB/s)Reading package lists...Reading package lists...Building dependency tree...Reading state information...The following NEW packages will be installed: libcudnn60 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.Need to get 68.5 MB of archives.After this operation, 154 MB of additional disk space will be used.Get:1 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 libcudnn6 6.0.21-1+cuda8.0 [68.5 MB]debconf: delaying package configuration, since apt-utils is not installedFetched 68.5 MB in 1min 44s (658 kB/s)Selecting previously unselected package libcudnn6.(Reading database ... 4887 files and directories currently installed.)Preparing to unpack .../libcudnn6_6.0.21-1+cuda8.0_amd64.deb ...Unpacking libcudnn6 (6.0.21-1+cuda8.0) ...Processing triggers for libc-bin (2.23-0ubuntu9) ...Setting up libcudnn6 (6.0.21-1+cuda8.0) ...Processing triggers for libc-bin (2.23-0ubuntu9) ... ---> ccfac2fb896cRemoving intermediate container eaa0a052e3f8Successfully built ccfac2fb896cSuccessfully tagged gemfield/ubuntu-runtime-cudnn:6.0gemfield@ai:~/AI/dockerfiles/cudnn/runtime$
3,運行docker images命令來查看生成的image:
gemfield@ai:~/AI/dockerfiles/cudnn/runtime$ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEgemfield/ubuntu-runtime-cudnn 6.0 ccfac2fb896c 5 minutes ago 935MBgemfield/ubuntu-devel-cuda 8.0 ab0c5b19d347 About an hour ago 1.68GBgemfield/ubuntu-runtime-cuda 8.0 d0b82ef8f4d2 2 hours ago 780MBnvidia/cuda latest f1193af0e70e 2 weeks ago 1.68GBubuntu 16.04 ccc7a11d65b1 2 weeks ago 120MBhello-world latest 1815c82652c0 2 months ago 1.84kBgemfield@ai:~/AI/dockerfiles/cudnn/runtime$
第三步:build NVIDIA cuDNN 開發版的 Docker image:
1,取得Ubuntu版的NVIDIA cuDNN 6.0 devel版本的Dockerfile:
下載:8.0/devel/cudnn6/Dockerfile · ubuntu16.04 · nvidia / cuda
然後放置到當前目錄(本步驟沒有使用上面的官方版本,而是使用了下面的版本),這個Dockerfile使用了 「gemfield/ubuntu-devel-cuda」 作為父 image。
FROM gemfield/ubuntu-devel-cuda:8.0LABEL maintainer "Gemfield <gemfield@civilnet.cn>"RUN echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.listENV CUDNN_VERSION 6.0.21LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}"RUN apt-get update && apt-get install -y --no-install-recommends libcudnn6=$CUDNN_VERSION-1+cuda8.0 libcudnn6-dev=$CUDNN_VERSION-1+cuda8.0 && rm -rf /var/lib/apt/lists/*
2,在包含上面Dockerfile的當前目錄,執行Docker build命令來生成"gemfield/ubuntu-devel-cudnn:6.0" Docker image:
gemfield@ai:~/AI/dockerfiles/cudnn/devel$ docker build -t "gemfield/ubuntu-devel-cudnn:6.0" .Sending build context to Docker daemon 2.56kBStep 1/6 : FROM gemfield/ubuntu-devel-cuda:8.0 ---> ab0c5b19d347Step 2/6 : LABEL maintainer "Gemfield <gemfield@civilnet.cn>" ---> Running in d8ed897a46ee ---> 741522f70e05Removing intermediate container d8ed897a46eeStep 3/6 : RUN echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list ---> Running in 7ed8328e5e17 ---> 60273b49a65aRemoving intermediate container 7ed8328e5e17Step 4/6 : ENV CUDNN_VERSION 6.0.21 ---> Running in 33040bd35d03 ---> 4832cc2661bcRemoving intermediate container 33040bd35d03Step 5/6 : LABEL com.nvidia.cudnn.version "${CUDNN_VERSION}" ---> Running in bf981254f3b6 ---> 83a256035a47Removing intermediate container bf981254f3b6Step 6/6 : RUN apt-get update && apt-get install -y --no-install-recommends libcudnn6=$CUDNN_VERSION-1+cuda8.0 libcudnn6-dev=$CUDNN_VERSION-1+cuda8.0 && rm -rf /var/lib/apt/lists/* ---> Running in 7927fb83c83bGet:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]Ign:3 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 InReleaseIgn: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://security.ubuntu.com/ubuntu xenial-security/universe Sources [46.8 kB]Get:7 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Release [564 B]Get:8 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [441 kB]Get:9 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 Release.gpg [801 B]Get:10 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Release.gpg [801 B]Get:11 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 Packages [66.0 kB]Get:12 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.8 kB]Get:13 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [204 kB]Get:14 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [2935 B]Get:15 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Packages [8408 B]Get:16 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]Get:17 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]Get:18 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]Get:19 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 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 [9827 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 [214 kB]Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [799 kB]Get:25 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.6 kB]Get:26 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [666 kB]Get:27 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [17.5 kB]Get:28 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [5177 B]Get:29 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [6236 B]Fetched 24.4 MB in 34s (708 kB/s)Reading package lists...Reading package lists...Building dependency tree...Reading state information...The following NEW packages will be installed: libcudnn6 libcudnn6-dev0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.Need to get 128 MB of archives.After this operation, 298 MB of additional disk space will be used.Get:1 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 libcudnn6 6.0.21-1+cuda8.0 [68.5 MB]Get:2 http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 libcudnn6-dev 6.0.21-1+cuda8.0 [59.9 MB]debconf: delaying package configuration, since apt-utils is not installedFetched 128 MB in 2min 44s (779 kB/s)Selecting previously unselected package libcudnn6.(Reading database ... 11141 files and directories currently installed.)Preparing to unpack .../libcudnn6_6.0.21-1+cuda8.0_amd64.deb ...Unpacking libcudnn6 (6.0.21-1+cuda8.0) ...Selecting previously unselected package libcudnn6-dev.Preparing to unpack .../libcudnn6-dev_6.0.21-1+cuda8.0_amd64.deb ...Unpacking libcudnn6-dev (6.0.21-1+cuda8.0) ...Processing triggers for libc-bin (2.23-0ubuntu9) ...Setting up libcudnn6 (6.0.21-1+cuda8.0) ...Setting up libcudnn6-dev (6.0.21-1+cuda8.0) ...update-alternatives: using /usr/include/x86_64-linux-gnu/cudnn_v6.h to provide /usr/include/cudnn.h (libcudnn) in auto modeProcessing triggers for libc-bin (2.23-0ubuntu9) ... ---> 441e2eab5c7eRemoving intermediate container 7927fb83c83bSuccessfully built 441e2eab5c7eSuccessfully tagged gemfield/ubuntu-devel-cudnn:6.0gemfield@ai:~/AI/dockerfiles/cudnn/devel$
3,運行docker images命令來查看生成的image:
gemfield@ai:~/AI/dockerfiles/cudnn/devel$ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEgemfield/ubuntu-devel-cudnn 6.0 441e2eab5c7e 56 seconds ago 1.98GBgemfield/ubuntu-runtime-cudnn 6.0 ccfac2fb896c 16 hours ago 935MBgemfield/ubuntu-devel-cuda 8.0 ab0c5b19d347 17 hours ago 1.68GBgemfield/ubuntu-runtime-cuda 8.0 d0b82ef8f4d2 18 hours ago 780MBnvidia/cuda latest f1193af0e70e 2 weeks ago 1.68GBubuntu 16.04 ccc7a11d65b1 2 weeks ago 120MBhello-world latest 1815c82652c0 2 months ago 1.84kBgemfield@ai:~/AI/dockerfiles/cudnn/devel$
第四步:上傳這兩個cuDNN Docker image到Docker Hub:
參考Gemfield專欄文章:在Ubuntu 16.04上製作 NVIDIA CUDA Docker image
第五步:使用這些Docker image
參考Gemfield專欄文章:在Ubuntu 16.04上製作 NVIDIA CUDA Docker image
推薦閱讀:
TAG:NVIDIA英偉達 | Docker | Caffe深度學習框架 |