在 POP OS 21.10 环境下安装 nvidia-docker2 时运行
docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
报如下错误
docker: Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: Running hook #0:: error running hook: exit status 1, stdout: , stderr: nvidia-container-cli: container error: cgroup subsystem devices not found: unknown.
解决方法:
添加 nvidia-docker apt 库
distribution=ubuntu20.04 && \
&& curl -s -L https://nvidia.github.io/libnvidia-container/gpgkey | sudo apt-key add - \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
之后运行:
sudo nano /etc/apt/preferences.d/pop-default-settings
在 末尾添加(目的是增加 nvidia 仓库的引用优先级
Package: *
Pin: origin nvidia.github.io
Pin-Priority: 1002
然后于运行
sudo apt update \
&& sudo apt install nvidia-docker2 \
&& sudo systemctl restart docker
安装完成后再运行
docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
应该就会有正确的输出了:
Sat Mar 26 09:30:27 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.86 Driver Version: 470.86 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:01:00.0 On | N/A |
| N/A 36C P5 14W / N/A | 303MiB / 5946MiB | 1% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
解决方案来自:(感谢大佬