Ubuntu 18.04 で NVIDIA-DOCKER 2 を使おうとしたらハマった
結論から言うと docker-ce を捨てて docker.io を入れましょう。
環境
NVIDIA-DOCKER 2 インストール手順
負けイベント
エラーの説明から。頑張って docker-ce 入れてから apt-get install nvidia-docker2
を走らせるとこんなエラーメッセージが出ます。
The following NEW packages will be installed: bridge-utils{a} docker.io{a} libnvidia-container-tools{a} libnvidia-container1{a} nvidia-container-runtime{a} nvidia-container-runtime-hook{a} nvidia-docker2 ubuntu-fan{a} 0 packages upgraded, 8 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/32.5 MB of archives. After unpacking 147 MB will be used. The following packages have unmet dependencies: docker-ce : Conflicts: docker.io but 17.12.1-0ubuntu1 is to be installed The following actions will resolve these dependencies: Remove the following packages: 1) docker-ce [18.05.0~ce~2.1.rc1-0~ubuntu (bionic, now)]
しょうがないのでイチから出直しです。
再出発
docker-ce を入れてしまったひとはアンインストールしてください。まだ入れて無ければここはスキップ。
sudo apt-get purge docker-ce
新たな武器
代わりにdocker.ioを入れます
sudo apt-get update
sudo apt-get install -y docker.io
腕試し
とりあえず docker の動作確認
sudo docker run hello-world
こんな感じの出力が出ればOK
Hello from Docker! This message shows that your installation appears to be working correctly. ... (省略)
未開の地へ
ここからはNVIDIA-Dockerの公式サイト(https://github.com/NVIDIA/nvidia-docker)にしたがって入れる
以下は公式サイトからの転載。
# Add the package repositories 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 # Install nvidia-docker2 and reload the Docker daemon configuration sudo apt-get install -y nvidia-docker2 sudo pkill -SIGHUP dockerd
エンドロール
sudo docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
いつもの nvidia-smi な画面が出ればめでたしめでたし。終わり。
DLC
必要に応じて docker グループに自分を足しておきましょう
sudo gpasswd -a `whoami` docker
再起動も忘れずに
参考サイト
NVIDIAの中のひとが『docker-ce の Ubuntu18.04 版はまだ出てないから先走るな』と言っています↓
https://github.com/NVIDIA/nvidia-docker/issues/643#issuecomment-384806571