docker-ce の配布サイトを apt-get に登録する。docker-ce のインストールは、次項の nvidia-docker2 のインストール時に、その依存アプリとしてインストールする。
$ sudo apt-get -y update $ sudo apt-get -y install curl apt-transport-https ca-certificates curl software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable test edge"
https://github.com/NVIDIA/nvidia-docker
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - $ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) $ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list $ sudo apt-get update $ sudo apt-get install -y nvidia-docker2 $ sudo pkill -SIGHUP dockerd
https://github.com/docker/compose/releases
$ sudo -s # curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` \ -o /usr/local/bin/docker-compose # chmod +x /usr/local/bin/docker-compose # exit $ docker-compose -version docker-compose version 1.23.2, build 1110ad01
$ sudo docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi Sat Jan 5 09:59:00 2019 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 410.93 Driver Version: 410.93 CUDA Version: 10.0 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce RTX 2070 Off | 00000000:01:00.0 Off | N/A | | 19% 23C P8 21W / 175W | 8MiB / 7952MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| +-----------------------------------------------------------------------------+
$ sudo docker run --runtime=nvidia --rm nvidia/cuda nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2018 NVIDIA Corporation Built on Sat_Aug_25_21:08:01_CDT_2018 Cuda compilation tools, release 10.0, V10.0.130
Docker Compose 版
version: '2.3'
services:
nvidia:
image: nvidia/cuda
runtime: nvidia
command: nvidia-smi
~/Docker/sample$ sudo docker-compose up Creating network "sample_default" with the default driver Creating sample_nvidia_1 ... done Attaching to sample_nvidia_1 nvidia_1 | Sat Jan 5 13:07:58 2019 nvidia_1 | +-----------------------------------------------------------------------------+ nvidia_1 | | NVIDIA-SMI 410.93 Driver Version: 410.93 CUDA Version: 10.0 | nvidia_1 | |-------------------------------+----------------------+----------------------+ nvidia_1 | | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | nvidia_1 | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | nvidia_1 | |===============================+======================+======================| nvidia_1 | | 0 GeForce RTX 2070 Off | 00000000:01:00.0 Off | N/A | nvidia_1 | | 19% 22C P8 19W / 175W | 8MiB / 7952MiB | 0% Default | nvidia_1 | +-------------------------------+----------------------+----------------------+ nvidia_1 | nvidia_1 | +-----------------------------------------------------------------------------+ nvidia_1 | | Processes: GPU Memory | nvidia_1 | | GPU PID Type Process name Usage | nvidia_1 | |=============================================================================| nvidia_1 | +-----------------------------------------------------------------------------+ sample_nvidia_1 exited with code 0
$ sudo groupadd docker $ sudo gpasswd -a $USER docker $ sudo systemctl restart docker
設定を反映するには X-Window 上でのログオフ・ログインが必要
$ echo docker-ce hold | sudo dpkg --set-selections $ echo docker-ce-cli hold | sudo dpkg --set-selections $ sudo dpkg --get-selections | grep docker docker-ce hold docker-ce-cli hold nvidia-docker2 installこれで、nivida-docker2 の更新だけが有効になった
$ echo [package] install | sudo dpkg --set-selections
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "/usr/bin/nvidia-container-runtime",
"runtimeArgs": []
}
}
}
$ sudo systemctl restart docker
$ docker run --rm nvidia/cuda nvidia-smi Wed Feb 20 17:07:03 2019 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 410.93 Driver Version: 410.93 CUDA Version: 10.0 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce RTX 2070 Off | 00000000:01:00.0 Off | N/A | | 18% 28C P8 19W / 175W | 8MiB / 7952MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| +-----------------------------------------------------------------------------+