NVIDIA : Container Toolkit インストール2022/07/07 |
NVIDIA Container Toolkit をインストールすると、コンテナーから GPU を容易に利用可能となります。
|
|
[1] | |
[2] | |
[3] | NVIDIA Container Toolkit をインストールします。 |
[root@dlp ~]# curl https://nvidia.github.io/nvidia-docker/rhel9.0/nvidia-docker.repo > /etc/yum.repos.d/nvidia-docker.repo [root@dlp ~]# dnf -y install nvidia-container-toolkit |
[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 可能な Cuda イメージのタグ確認 [root@dlp ~]# curl -s https://registry.hub.docker.com/v1/repositories/nvidia/cuda/tags | sed "s/,/\n/g" | grep name "name": "10.0-base"} "name": "10.0-base-centos6"} "name": "10.0-base-centos7"} "name": "10.0-base-ubi7"} "name": "10.0-base-ubuntu14.04"} "name": "10.0-base-ubuntu16.04"} "name": "10.0-base-ubuntu18.04"} ..... ..... # Cuda 11.7 コンテナーイメージを Pull して [nvidia-smi] # UBI = Red Hat Universal Base Image [root@dlp ~]# podman run -e NVIDIA_VISIBLE_DEVICES=all nvidia/cuda:11.7.0-base-ubi8 nvidia-smi Thu Jul 7 00:49:11 2022 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 515.48.07 Driver Version: 515.48.07 CUDA Version: 11.7 | |-------------------------------+----------------------+----------------------+ | 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 ... Off | 00000000:05:00.0 Off | N/A | | 0% 53C P5 15W / 120W | 0MiB / 6144MiB | 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 ~]# podman run -it -e NVIDIA_VISIBLE_DEVICES=all nvidia/cuda:11.7.0-base-ubi8 bash [root@f0e253351135 /]# nvidia-smi
Thu Jul 7 00:56:35 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.48.07 Driver Version: 515.48.07 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| 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 ... Off | 00000000:05:00.0 Off | N/A |
| 0% 52C P5 16W / 120W | 0MiB / 6144MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
[root@f0e253351135 /]# exit
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/nvidia/cuda 11.7.0-base-ubi8 96566dad7ca7 7 weeks ago 359 MB |
Sponsored Link |