NVIDIA : Container Toolkit インストール2025/08/07 |
|
NVIDIA Container Toolkit をインストールすると、コンテナーから GPU を容易に利用可能となります。 |
|
| [1] | |
| [2] | |
| [3] | NVIDIA Container Toolkit をインストールします。 |
|
[root@dlp ~]#
dnf config-manager --add-repo https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo Adding repo from: https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo
[root@dlp ~]#
[root@dlp ~]# dnf -y install nvidia-container-toolkit systemctl restart docker
|
| [4] | SELinux を有効にしている場合は、ポリシーの変更が必要です。 |
|
[root@dlp ~]# setsebool -P container_use_devices on
[root@dlp ~]#
vi nvidiasmi.te # 以下の内容で新規作成
module nvidiasmi 1.0;
require {
type xserver_misc_device_t;
type container_t;
type container_runtime_tmpfs_t;
class file { open read };
class chr_file { ioctl open read write };
}
#============= container_t ==============
allow container_t container_runtime_tmpfs_t:file { open read };
checkmodule -m -M -o nvidiasmi.mod nvidiasmi.te [root@dlp ~]# semodule_package --outfile nvidiasmi.pp --module nvidiasmi.mod [root@dlp ~]# semodule -i nvidiasmi.pp |
| [5] | コンテナーからの [nvidia-smi] コマンドの利用方法です。 Pull 可能なコンテナーイメージは下記サイトで検索可能です。 ⇒ https://hub.docker.com/r/nvidia/cuda/tags |
|
[root@dlp ~]# docker pull nvidia/cuda:12.9.1-cudnn-runtime-ubuntu24.04 [root@dlp ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nvidia/cuda 12.9.1-cudnn-runtime-ubuntu24.04 1fb7ebfe77ba 2 weeks ago 4.91GB quay.io/centos/centos stream10 02ae49ff109e 7 weeks ago 306MB[root@dlp ~]# docker run --gpus all nvidia/cuda:12.9.1-cudnn-runtime-ubuntu24.04 nvidia-smi ========== == CUDA == ========== CUDA Version 12.9.1 Container image Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. This container image and its contents are governed by the NVIDIA Deep Learning Container License. By pulling and using the container, you accept the terms and conditions of this license: https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license A copy of this license is made available in this container at /NGC-DL-CONTAINER-LICENSE for your convenience. Thu Aug 7 05:13:34 2025 +-----------------------------------------------------------------------------------------+ | NVIDIA-SMI 580.65.06 Driver Version: 580.65.06 CUDA Version: 13.0 | +-----------------------------------------+------------------------+----------------------+ | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+========================+======================| | 0 NVIDIA GeForce RTX 3060 Off | 00000000:07:00.0 Off | N/A | | 0% 58C P8 11W / 170W | 1MiB / 12288MiB | 0% Default | | | | N/A | +-----------------------------------------+------------------------+----------------------+ +-----------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=========================================================================================| | No running processes found | +-----------------------------------------------------------------------------------------+ # 対話セッションから [nvidia-smi] [root@dlp ~]# docker run --gpus all -it nvidia/cuda:12.9.1-cudnn-runtime-ubuntu24.04 /bin/bash root@68d0d6fb1cd4:/# nvidia-smi
Thu Aug 7 05:15:03 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 580.65.06 Driver Version: 580.65.06 CUDA Version: 13.0 |
+-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 3060 Off | 00000000:07:00.0 Off | N/A |
| 0% 58C P8 11W / 170W | 1MiB / 12288MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
+-----------------------------------------------------------------------------------------+
root@68d0d6fb1cd4:/# exit
|
| Sponsored Link |
|
|