Nvidia cuda-10.0+cuDNN-7.3のdocker imageをビルドする

いつの間にかにNvidiaからcuda10とcudnn7.3がリリースされていたので早速使ってみることにした。取り敢えずは、pytorchとcaffe2をcuda10+cudnn7.3でビルドしてからベンチマークテストをしてみようと思う。

スポンサーリンク

dockerfileを作成する

mydocker/cu10フォルダに移動する。

cd mydocker/cu10
/home/nobu/mydocker/cu10

dockerfileを作成する。

%%writefile Dockerfile

FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
ENV NVIDIA_DRIVER_CAPABILITIES all

    RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    apt-utils \
    nano \
    git \
    curl && \
    apt-get autoremove && apt-get autoclean && \
    rm -rf /var/lib/apt/lists/*
Overwriting Dockerfile

dockerfileをビルドする

!nvidia-docker build . -t cu10
Sending build context to Docker daemon  3.584kB
Step 1/3 : FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
 ---> 78eb5b07b059
Step 2/3 : ENV NVIDIA_DRIVER_CAPABILITIES all
 ---> Using cache
 ---> d985da822bbe
Step 3/3 : RUN apt-get update && apt-get install -y --no-install-recommends     build-essential     apt-utils     nano     git     curl &&     apt-get autoremove && apt-get autoclean &&     rm -rf /var/lib/apt/lists/*
 ---> Running in 9e64e78b386c
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
Ign:3 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  InRelease
Ign:4 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64  InRelease
Get:5 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  Release [564 B]
Get:6 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64  Release [564 B]
Get:7 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  Release.gpg [819 B]
Get:8 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64  Release.gpg [801 B]
Get:9 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:11 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  Packages [23.9 kB]
Get:12 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64  Packages [1981 B]
Get:13 http://security.ubuntu.com/ubuntu bionic-security/universe Sources [19.2 kB]
Get:14 http://archive.ubuntu.com/ubuntu bionic/universe Sources [11.5 MB]
Get:15 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [213 kB]
Get:16 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [80.8 kB]
Get:17 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [1363 B]
Get:18 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1344 kB]
Get:19 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB]
Get:20 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [13.5 kB]
Get:21 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB]
Get:22 http://archive.ubuntu.com/ubuntu bionic-updates/universe Sources [77.1 kB]
Get:23 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [452 kB]
Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [260 kB]
Get:25 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [4360 B]
Get:26 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [2975 B]
Fetched 26.0 MB in 7s (3562 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
build-essential is already the newest version (12.4ubuntu1).
build-essential set to manually installed.
The following additional packages will be installed:
  git-man libapt-inst2.0 libcurl3-gnutls libcurl4 liberror-perl libexpat1
  libgssapi-krb5-2 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0
  libnghttp2-14 libpsl5 librtmp1
Suggested packages:
  gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-el git-email
  git-gui gitk gitweb git-cvs git-mediawiki git-svn krb5-doc krb5-user spell
Recommended packages:
  less ssh-client krb5-locales publicsuffix
The following NEW packages will be installed:
  apt-utils curl git git-man libapt-inst2.0 libcurl3-gnutls libcurl4
  liberror-perl libexpat1 libgssapi-krb5-2 libk5crypto3 libkeyutils1 libkrb5-3
  libkrb5support0 libnghttp2-14 libpsl5 librtmp1 nano
0 upgraded, 18 newly installed, 0 to remove and 1 not upgraded.
Need to get 6591 kB of archives.
After this operation, 40.4 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libapt-inst2.0 amd64 1.6.3ubuntu0.1 [55.6 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 apt-utils amd64 1.6.3ubuntu0.1 [208 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic/main amd64 libexpat1 amd64 2.2.5-3 [80.2 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic/main amd64 libkrb5support0 amd64 1.16-2build1 [31.1 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic/main amd64 libk5crypto3 amd64 1.16-2build1 [85.6 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic/main amd64 libkeyutils1 amd64 1.5.9-9.2ubuntu2 [8720 B]
Get:7 http://archive.ubuntu.com/ubuntu bionic/main amd64 libkrb5-3 amd64 1.16-2build1 [279 kB]
Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgssapi-krb5-2 amd64 1.16-2build1 [122 kB]
Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 libpsl5 amd64 0.19.1-5build1 [41.8 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic/main amd64 nano amd64 2.9.3-2 [231 kB]
Get:11 http://archive.ubuntu.com/ubuntu bionic/main amd64 libnghttp2-14 amd64 1.30.0-1ubuntu1 [77.8 kB]
Get:12 http://archive.ubuntu.com/ubuntu bionic/main amd64 librtmp1 amd64 2.4+20151223.gitfa8646d.1-1 [54.2 kB]
Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcurl4 amd64 7.58.0-2ubuntu3.3 [214 kB]
Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 curl amd64 7.58.0-2ubuntu3.3 [159 kB]
Get:15 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcurl3-gnutls amd64 7.58.0-2ubuntu3.3 [212 kB]
Get:16 http://archive.ubuntu.com/ubuntu bionic/main amd64 liberror-perl all 0.17025-1 [22.8 kB]
Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 git-man all 1:2.17.1-1ubuntu0.1 [803 kB]
Get:18 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 git amd64 1:2.17.1-1ubuntu0.1 [3905 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 6591 kB in 3s (2156 kB/s)
Selecting previously unselected package libapt-inst2.0:amd64.
(Reading database ... 11485 files and directories currently installed.)
Preparing to unpack .../00-libapt-inst2.0_1.6.3ubuntu0.1_amd64.deb ...
Unpacking libapt-inst2.0:amd64 (1.6.3ubuntu0.1) ...
Selecting previously unselected package apt-utils.
Preparing to unpack .../01-apt-utils_1.6.3ubuntu0.1_amd64.deb ...
Unpacking apt-utils (1.6.3ubuntu0.1) ...
Selecting previously unselected package libexpat1:amd64.
Preparing to unpack .../02-libexpat1_2.2.5-3_amd64.deb ...
Unpacking libexpat1:amd64 (2.2.5-3) ...
Selecting previously unselected package libkrb5support0:amd64.
Preparing to unpack .../03-libkrb5support0_1.16-2build1_amd64.deb ...
Unpacking libkrb5support0:amd64 (1.16-2build1) ...
Selecting previously unselected package libk5crypto3:amd64.
Preparing to unpack .../04-libk5crypto3_1.16-2build1_amd64.deb ...
Unpacking libk5crypto3:amd64 (1.16-2build1) ...
Selecting previously unselected package libkeyutils1:amd64.
Preparing to unpack .../05-libkeyutils1_1.5.9-9.2ubuntu2_amd64.deb ...
Unpacking libkeyutils1:amd64 (1.5.9-9.2ubuntu2) ...
Selecting previously unselected package libkrb5-3:amd64.
Preparing to unpack .../06-libkrb5-3_1.16-2build1_amd64.deb ...
Unpacking libkrb5-3:amd64 (1.16-2build1) ...
Selecting previously unselected package libgssapi-krb5-2:amd64.
Preparing to unpack .../07-libgssapi-krb5-2_1.16-2build1_amd64.deb ...
Unpacking libgssapi-krb5-2:amd64 (1.16-2build1) ...
Selecting previously unselected package libpsl5:amd64.
Preparing to unpack .../08-libpsl5_0.19.1-5build1_amd64.deb ...
Unpacking libpsl5:amd64 (0.19.1-5build1) ...
Selecting previously unselected package nano.
Preparing to unpack .../09-nano_2.9.3-2_amd64.deb ...
Unpacking nano (2.9.3-2) ...
Selecting previously unselected package libnghttp2-14:amd64.
Preparing to unpack .../10-libnghttp2-14_1.30.0-1ubuntu1_amd64.deb ...
Unpacking libnghttp2-14:amd64 (1.30.0-1ubuntu1) ...
Selecting previously unselected package librtmp1:amd64.
Preparing to unpack .../11-librtmp1_2.4+20151223.gitfa8646d.1-1_amd64.deb ...
Unpacking librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1) ...
Selecting previously unselected package libcurl4:amd64.
Preparing to unpack .../12-libcurl4_7.58.0-2ubuntu3.3_amd64.deb ...
Unpacking libcurl4:amd64 (7.58.0-2ubuntu3.3) ...
Selecting previously unselected package curl.
Preparing to unpack .../13-curl_7.58.0-2ubuntu3.3_amd64.deb ...
Unpacking curl (7.58.0-2ubuntu3.3) ...
Selecting previously unselected package libcurl3-gnutls:amd64.
Preparing to unpack .../14-libcurl3-gnutls_7.58.0-2ubuntu3.3_amd64.deb ...
Unpacking libcurl3-gnutls:amd64 (7.58.0-2ubuntu3.3) ...
Selecting previously unselected package liberror-perl.
Preparing to unpack .../15-liberror-perl_0.17025-1_all.deb ...
Unpacking liberror-perl (0.17025-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../16-git-man_1%3a2.17.1-1ubuntu0.1_all.deb ...
Unpacking git-man (1:2.17.1-1ubuntu0.1) ...
Selecting previously unselected package git.
Preparing to unpack .../17-git_1%3a2.17.1-1ubuntu0.1_amd64.deb ...
Unpacking git (1:2.17.1-1ubuntu0.1) ...
Setting up libapt-inst2.0:amd64 (1.6.3ubuntu0.1) ...
Setting up git-man (1:2.17.1-1ubuntu0.1) ...
Setting up libexpat1:amd64 (2.2.5-3) ...
Setting up libnghttp2-14:amd64 (1.30.0-1ubuntu1) ...
Setting up liberror-perl (0.17025-1) ...
Setting up apt-utils (1.6.3ubuntu0.1) ...
Setting up libpsl5:amd64 (0.19.1-5build1) ...
Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1) ...
Setting up libkrb5support0:amd64 (1.16-2build1) ...
Setting up nano (2.9.3-2) ...
update-alternatives: using /bin/nano to provide /usr/bin/editor (editor) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/editor.1.gz because associated file /usr/share/man/man1/nano.1.gz (of link group editor) doesn't exist
update-alternatives: using /bin/nano to provide /usr/bin/pico (pico) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/pico.1.gz because associated file /usr/share/man/man1/nano.1.gz (of link group pico) doesn't exist
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up libkeyutils1:amd64 (1.5.9-9.2ubuntu2) ...
Setting up libk5crypto3:amd64 (1.16-2build1) ...
Setting up libkrb5-3:amd64 (1.16-2build1) ...
Setting up libgssapi-krb5-2:amd64 (1.16-2build1) ...
Setting up libcurl3-gnutls:amd64 (7.58.0-2ubuntu3.3) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3.3) ...
Setting up git (1:2.17.1-1ubuntu0.1) ...
Setting up curl (7.58.0-2ubuntu3.3) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Reading package lists...
Building dependency tree...
Reading state information...
Removing intermediate container 9e64e78b386c
 ---> 8832f1c9dbc8
Successfully built 8832f1c9dbc8
Successfully tagged cu10:latest

docker imageを確認する

dockerビルドが成功したのでイメージを確認する。

!docker images
REPOSITORY          TAG                             IMAGE ID            CREATED             SIZE
cu10                latest                          8832f1c9dbc8        2 minutes ago       2.95GB
nvidia/cuda         10.0-cudnn7-devel-ubuntu18.04   78eb5b07b059        4 days ago          2.91GB
<none>              <none>                          b2f5e4b609f5        4 weeks ago         78.6GB

ちゃんと出来上がったので、このイメージを使ってcuda10を試してみる。