内容目录
参考文档:https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
安装驱动
系统环境是 fnOS v0.8.34(Debian 12),按照如下命令安装驱动即可:
sudo apt install nvidia-tesla-470-driver
安装完驱动要重启,重启完使用命令 nvidia-smi
即可查看显卡状态:
madray@nas:~$ sudo nvidia-smi
Sun Jan 19 20:35:47 2025
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.256.02 Driver Version: 470.256.02 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| 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:03:00.0 N/A | N/A |
| N/A 29C P8 N/A / N/A | 3MiB / 1997MiB | N/A Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
设置 Docker 显卡直通
添加软件仓库:
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
安装 nvidia-container-toolkit
:
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
设置 Docker 显卡直通能力(nvidia-ctk
会自动完成对 /etc/docker/daemon.json
的修改):
sudo nvidia-ctk runtime configure --runtime=docker
最后重启 docker:
sudo systemctl restart docker