Ubuntu18.04にDoker19.03環境構築(+NVIDIA Container Toolkit)
参考文献
本ページは以下を参考にしています。
概要
Dockerを使えば
- 環境を汚すことなくCUDA ToolkitやcuDNNのバージョンが変えられる
- 環境構築に要する時間が短くなる
と聞いたので上記ページを参考に自身の環境にDocker環境を構築しました。
自身の備忘録ですので、参考程度にご覧ください。
手順1 Dockerのインストール
Install Docker Engine on Ubuntuに従って進めます。
-
古いDockerの削除
$ sudo apt-get remove docker docker-engine docker.io containerd runc
-
リポジトリの設定
$ 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 # x86_64 / amd64 の場合 $ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
-
Docker Engineのインストール
$ sudo apt-get update # 最新版をインストール(特定のバージョンをインストールする方法は公式ページを参照) $ sudo apt-get install docker-ce docker-ce-cli containerd.io # 再起動 $ sudo reboot
-
確認
$ sudo docker run hello-world # --- 以下のような情報が出力される --- # Unable to find image 'hello-world:latest' locally # latest: Pulling from library/hello-world # 0e03bdcc26d7: Pull complete # Digest: sha256:d58e752213a51785838f9eed2b7a498ffa1cb3aa7f946dda11af39286c3db9a9 # Status: Downloaded newer image for hello-world:latest # # Hello from Docker! # This message shows that your installation appears to be working correctly. # # To generate this message, Docker took the following steps: # 1. The Docker client contacted the Docker daemon. # 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. # (amd64) # 3. The Docker daemon created a new container from that image which runs the # executable that produces the output you are currently reading. # 4. The Docker daemon streamed that output to the Docker client, which sent it # to your terminal. # # To try something more ambitious, you can run an Ubuntu container with: # $ docker run -it ubuntu bash # # Share images, automate workflows, and more with a free Docker ID: # https://hub.docker.com/ # # For more examples and ideas, visit: # https://docs.docker.com/get-started/
手順2 NVIDIA Container Toolkitのインストール
NVIDIA/nvidia-dockerのQuickstartに従って進めます。
-
リポジトリ追加
$ 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 # Dockerリスタート $ sudo systemctl restart docker
-
確認
# CUDA10.0,すべてのGPUを使用 docker run --gpus all nvidia/cuda:10.0-base nvidia-smi
おまけ 非toot権限でDockerコマンド使用
Post-installation steps for Linuxに従って進めます。
-
docker
グループの作成$ sudo groupadd docker
-
ユーザーの追加
$ sudo usermod -aG docker $USER
-
設定の反映(ログアウト&ログイン or 以下コマンド実行)
$ newgrp docker
-
確認
$ docker run hello-world
感想
インストールは手順がしっかり記載されていたため、特に問題なくできました。
ただ、Dockerの使い方が全然わかりません(笑)
Author And Source
この問題について(Ubuntu18.04にDoker19.03環境構築(+NVIDIA Container Toolkit)), 我々は、より多くの情報をここで見つけました https://qiita.com/yto1292/items/533fae4e0539df37fe38著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .