0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VMにDockerでCUDA環境を作成するまでの手順

Posted at

本記事の趣旨

基本的に本記事は,研究室内の引き継ぎを目的として資料作成しております.
自分用にも残したいので記事として公開します.

環境

学校から提供されているVMを利用します.

OS: Ubuntu 22.04.3 LTS x86_64
CPU: Intel(R) Xeon(R) Gold 6338 CPU @ 2.00GHz
GPU: NVIDIA 07:00.0 NVIDIA Corporation Device 2331
Memory: 684MiB / 62723MiB

Dockerを用いたCUDA環境の作成

学習に利用するCUDAとcuDNNの導入手順を示します.
nvidia driverはすでにあたっているので特に触る必要はありません.今回はDockerを利用して仮想環境内でCUDAとcuDNNを導入します.

Docker Engine のインストール

dockerのインストールを行います.

terminal
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

これでDockerのインストールが完了するはずです.
以下のコマンドで確認してください.

terminal
sudo docker version

バージョンが表示されれば成功です.

NVIDIA Container Toolkitインストール

Docker内でのGPU動作に必要なNVIDIA Container Tooolkitをインストールします.

まず,以下のコマンドでリポジトリ登録を行います.

terminal
 curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
    sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg   && curl -s -L      https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

登録したリポジトリを反映してnvidia containerをインストールし,Dockerデーモンを設定し再起動を行います.

terminal
sudo apt update
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

以上で環境構築は完了となります.

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?