1. 安装方式
1. 在线安装
# 默认安装位置:/usr/bin/
sudo apt-get install nvidia-container-runtime
2. 离线安装
- 获取离线安装包。
- 域名配置
```bash
通过域名查询IP
https://ip.tool.chinaz.com/
https://site.ip138.com/
配置域名解析
vi /etc/hosts
添加以下条目
185.199.109.153 nvidia.github.io
- **安装apt-transport-https**
```bash
wget http://ftp.hk.debian.org/debian/pool/main/a/apt/apt-transport-https_1.0.9.8.4_amd64.deb
dpkg -i apt-transport-https_*_amd64.deb
软件源配置
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
联网下载安装包
apt-get download libnvidia-container1
apt-get download libnvidia-container-tools
apt-get download nvidia-container-runtime-hook
apt-get download nvidia-container-runtime
apt-get download nvidia-docker2
- 离线安装。
# 注意:顺序不能颠倒
dpkg -i libnvidia-container1_1.0.5-1_amd64.deb
dpkg -i libnvidia-container-tools_1.0.5-1_amd64.deb
dpkg -i nvidia-container-runtime-hook_1.4.0-1_amd64.deb
dpkg -i nvidia-container-runtime_2.0.0+docker18.06.2-1_amd64.deb
dpkg -i nvidia-docker2_2.0.3+docker18.06.2-1_all.deb
2. 配置
内容如下:# 配置默认nvidia运行(安装成功或一般会默认安装上)
sudo vi /etc/docker/daemon.json
重启Docker:{
"default-runtime": "nvidia"
"runtimes": {
"nvidia": {
"path": "/usr/bin/nvidia-container-runtime",
"runtimeArgs": []
}
}
}
# 重启docker服务即可生效
sudo systemctl daemon-reload
sudo systemctl restart docker
3. 验证
sudo docker run --runtime=nvidia --rm hello-world
sudo docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi
4. 移除
sudo apt-get purge libnvidia-container1
sudo apt-get purge libnvidia-container-tools
sudo apt-get purge nvidia-container-runtime-hook
sudo apt-get purge nvidia-container-runtime
sudo apt-get purge nvidia-docker2
参考
博文:docker 和 nvidia-docker 的离线安装和基本使用
https://fanfuhan.github.io/2019/11/22/docker_based_use/