Linux 安装 NVIDIA 驱动和容器工具包

查看 GPU 信息

1
lspci | grep -i nvidia

驱动

1
yum install -y kernel-devel gcc

Test

1
nvidia-smi

容器工具包

  • Install Guide
  • USTC Mirrors

Install

1
2
curl -s -L https://mirrors.ustc.edu.cn/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo | \
sed 's#nvidia.github.io#mirrors.ustc.edu.cn#g' | tee /etc/yum.repos.d/nvidia-container-toolkit.repo
1
yum install -y nvidia-container-toolkit

Configure

1
nvidia-ctk runtime configure --runtime=docker

equivalent to edit /etc/docker/daemon.json add following content:

1
2
3
4
5
6
7
8
{
"runtimes": {
"nvidia": {
"args": [],
"path": "nvidia-container-runtime"
}
}
}

then restart docker daemon

1
systemctl restart docker

Test

1
docker run --rm --runtime=nvidia --gpus all ubuntu:24.04 nvidia-smi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 565.57.01 Driver Version: 565.57.01 CUDA Version: 12.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 Tesla T4 Off | 00000000:00:10.0 Off | 0 |
| N/A 24C P8 8W / 70W | 3MiB / 15360MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 1 Tesla T4 Off | 00000000:00:11.0 Off | 0 |
| N/A 25C P8 9W / 70W | 3MiB / 15360MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+

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