CentOS 8
Sponsored Link

NVIDIA Container Toolkit インストール2020/07/21

 
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] コマンドの利用方法です。
# Cuda 11.0 コンテナーイメージを Pull して [nvidia-smi]

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

Tue Jul 20 19:32:32 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.57       Driver Version: 450.57       CUDA Version: 11.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  GeForce GTX 1070    Off  | 00000000:05:00.0 Off |                  N/A |
| 27%   35C    P5    27W / 180W |      0MiB /  8119MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

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

# Cuda 10.0 コンテナーイメージを Pull して 対話セッションから [nvidia-smi]

[root@dlp ~]#
podman run -it -e NVIDIA_VISIBLE_DEVICES=all nvidia/cuda:10.0-base bash

root@81ccbb753393:/#
nvidia-smi

Tue Jul 20 19:37:10 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.57       Driver Version: 450.57       CUDA Version: 11.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  GeForce GTX 1070    Off  | 00000000:05:00.0 Off |                  N/A |
| 27%   36C    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                                                 |
+-----------------------------------------------------------------------------+

root@81ccbb753393:/# exit 

[root@dlp ~]#
podman images

REPOSITORY              TAG         IMAGE ID       CREATED        SIZE
docker.io/nvidia/cuda   11.0-base   27c1a1745519   4 days ago     125 MB
docker.io/nvidia/cuda   10.0-base   841d44dd4b3c   7 months ago   113 MB
関連コンテンツ