一、安装nvidia-container-toolkit
总之一句话:nvidia-docker和nvidia-docker2,nvidia-container-runtime 已经被英伟达迭代了,可以认为nvidia-container-toolkit是nvidia-docker和nvidia-docker2, nvidia-container-runtime 的替代品,想了解区别的可以看这篇文章:nvidia docker, nvidia docker2, nvidia container toolkits三者的区别-CSDN博客
nvidia-container-toolkit是一组软件包,它们包括一个容器运行时库和一些工具,可以自动配置容器来利用NVIDIA GPU。它支持不同的容器引擎,如Docker、containerd、LXC、Podman等
官方安装过程:Installing the NVIDIA Container Toolkit --- NVIDIA Container Toolkit 1.15.0 documentation
1、安装过程汇总
bash
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
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
2、重启docker
bash
sudo systemctl restart docker
3、测试
bash
sudo docker run --rm --gpus all nvidia/cuda:${根据网站查询得到} nvidia-smi
# 例如
sudo docker run --rm --gpus all nvidia/cuda:11.7.1-base-ubuntu20.04 nvidia-smi
4、ubuntu系统与对应的cuda版本
doc/supported-tags.md · master · nvidia / container-images / cuda · GitLab