LoginSignup
3
5

More than 3 years have passed since last update.

[2019-08-19] Ubuntu 18.04+Docker(19.03)+NVIDIA GPU環境セットアップ

Posted at

やり方がまた変わっていたのでメモしておきます。

$ grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Ubuntu 18.04.3 LTS"

(標準で入るドライバを無効化する作業がまず必要かもしれない)

Dockerのインストール

https://docs.docker.com/install/linux/docker-ce/ubuntu/
にしたがってやる。

$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
$ docker -v
Docker version 19.03.1, build 74b1e89

https://docs.docker.com/install/linux/linux-postinstall/
にしたがってやる。

$ sudo usermod -aG docker $USER
(logout -> login)
$ docker run hello-world
Hello from Docker!
...

NVIDIAドライバ

$ lspci | grep NVIDIA
00:09.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)

$ sudo apt install nvidia-headless-430 nvidia-utils-430

DockerのNVIDIA対応のためのパッケージ

https://github.com/NVIDIA/nvidia-docker
にしたがってやる。

$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
$ 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-container-toolkit

確認

$ sudo reboot

$ nvidia-smi
...
| NVIDIA-SMI 430.26       Driver Version: 430.26       CUDA Version: 10.2     |
...

$ docker run --gpus all --rm nvidia/cuda nvidia-smi
...
| NVIDIA-SMI 430.26       Driver Version: 430.26       CUDA Version: 10.2     |
...
3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5