なので、ローカルでCUDA ToolkitやcuDNNなどのGPGPUソフトウェアが不要であれば、手順1,2,5,6の順で作業していただければ、DockerコンテナでGPUを動かすことができます!!
1. Ubuntu 22.04 LTS (Jammy Jellyfish) インストール
2. NVIDIA driverインストール
5. Docker Engineインストール
6. NVIDIA Container Toolkitインストール
nvidiaドライバ インストール
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#installation
$ vi /etc/modprobe.d/blacklist-nouveau.conf blacklist nouveau options nouveau modeset=0 $ sudo update-initramfs -u $ lspci | grep -i nvidia 62:00.0 3D controller: NVIDIA Corporation GV100GL [Tesla V100 SXM2 16GB] (rev a1) $ dpkg -l | grep nvidia $ dpkg -l | grep cuda (→ 既存パッケージが入ってる場合は削除する) $ sudo ubuntu-drivers devices ERROR:root:aplay command not found == /sys/devices/pci0000:5d/0000:5d:00.0/0000:5e:00.0/0000:5f:0c.0/0000:62:00.0 == modalias : pci:v000010DEd00001DB1sv000010DEsd00001212bc03sc02i00 vendor : NVIDIA Corporation model : GV100GL [Tesla V100 SXM2 16GB] driver : nvidia-driver-450-server - distro non-free driver : nvidia-driver-535-server - distro non-free driver : nvidia-driver-390 - distro non-free driver : nvidia-driver-535 - distro non-free recommended driver : nvidia-driver-525-server - distro non-free driver : nvidia-driver-470 - distro non-free driver : nvidia-driver-525 - distro non-free driver : nvidia-driver-418-server - distro non-free driver : nvidia-driver-470-server - distro non-free driver : xserver-xorg-video-nouveau - distro free builtin (recommended の nvidia-driver-535 をインストール) $ sudo apt install --no-install-recommends nvidia-driver-535 $ sudo reboot (確認) $ nvidia-smi
muninプラグイン
nvidia_gpu_ - Wildcard plugin to monitor NVIDIA GPUs. Uses nvidia-smi utility, usually bundled with NVIDIA GPU driver, to obtain information.
https://gallery.munin-monitoring.org/plugins/munin-contrib/nvidia_gpu_/
https://github.com/munin-monitoring/contrib/blob/master/plugins/gpu/nvidia_gpu_
Docker Engineインストール
https://docs.docker.com/engine/install/ubuntu/
sudo apt install ca-certificates curl gnupg curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg echo \ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] 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 install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin (確認) sudo docker run hello-world (dockerをsudoなしで実行できるように、ユーザーをdockerグループに追加) sudo usermod -aG docker $USER newgrp docker docker version
NVIDIA Container Toolkitインストール
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \ && 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/$distribution/libnvidia-container.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 sudo apt update sudo apt install -y nvidia-container-toolkit (DockerデーモンにNVIDIA Container Runtimeを認識させる) sudo nvidia-ctk runtime configure --runtime=docker sudo systemctl restart docker (確認) docker run --rm --gpus all \ nvcr.io/nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04 \ bash -c "nvidia-smi; nvcc -V"