CentOS Stream 10

NVIDIA : Install Container Toolkit2025/08/07

 

Install NVIDIA Container Toolkit to use GPU on your Computer from Containers.

[1]

Install NVIDIA driver on base System, refer to here.

[2]

Install Docker, refer to here.

[3] Install 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 ~]#
dnf -y install nvidia-container-toolkit
[root@dlp ~]#
systemctl restart docker
[4] If SELinux is enabled, change policy like follows.
[root@dlp ~]#
setsebool -P container_use_devices on

[root@dlp ~]#
vi nvidiasmi.te
# create new

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 };

[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] This is how to use [nvidia-smi] from Containers.
You can find available cuda images on the site below.
⇒ 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                                                             |
+-----------------------------------------------------------------------------------------+

# connect to the interactive session and run [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 
Matched Content