CentOS Stream 8
Sponsored Link

NVIDIA Container Toolkit インストール2021/04/13

 
NVIDIA Container Toolkit をインストールすると、コンテナーから GPU を容易に利用可能となります。
[1]
[2]
[3] NVIDIA Container Toolkit をインストールします。
[root@dlp ~]#
curl https://nvidia.github.io/nvidia-docker/centos8/nvidia-docker.repo > /etc/yum.repos.d/nvidia-docker.repo

[root@dlp ~]#
dnf -y install nvidia-container-toolkit

[4] SELinux を有効にしている場合は、ポリシーの変更が必要です。
[root@dlp ~]#
vi nvidiasmi.te
# 以下の内容で新規作成

module nvidiasmi 1.0;

require {
        type container_runtime_tmpfs_t;
        type container_t;
        type xserver_misc_device_t;
        class file { open read };
        class chr_file { getattr ioctl open read write };
}

#============= container_t ==============
allow container_t container_runtime_tmpfs_t:file { open read };
allow container_t xserver_misc_device_t:chr_file { getattr ioctl open read write };

[root@dlp ~]#
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.0 コンテナーイメージを Pull して [nvidia-smi]

[root@dlp ~]#
podman run -e NVIDIA_VISIBLE_DEVICES=all nvidia/cuda:11.0-base nvidia-smi

Tue Apr 13 05:04:42 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.32.03    Driver Version: 460.32.03    CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| 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  GeForce GTX 1070    Off  | 00000000:05:00.0 Off |                  N/A |
| 27%   35C    P5    25W / 180W |      0MiB /  8119MiB |      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.0-base bash

root@39eec91a01d8:/#
nvidia-smi

Tue Apr 13 05:05:16 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.32.03    Driver Version: 460.32.03    CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| 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  GeForce GTX 1070    Off  | 00000000:05:00.0 Off |                  N/A |
| 27%   35C    P5    18W / 180W |      0MiB /  8119MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

root@39eec91a01d8:/# exit 

[root@dlp ~]#
podman images

REPOSITORY             TAG        IMAGE ID      CREATED       SIZE
docker.io/nvidia/cuda  11.0-base  2ec708416bb8  7 months ago  125 MB
関連コンテンツ