nvidia-docker runtime报错(Unknown runtime specified nvidia)

1 运行 docker 命令报错
root@test:~# docker run --runtime=nvidia -ti  -v $(pwd):/workspace -w /workspace -v /nfs:/nfs $@ --privileged -v /var/run/docker.sock:/var/run/docker.sock registry.test.cn/mla/cxx_toolchains:latest
docker: Error response from daemon: Unknown runtime specified nvidia.
See 'docker run --help'.

根据错误提示,查看 nvidia-docker 是否安装

root@test:~# nvidia-docker
nvidia-docker: command not found
root@test:~# 

很明显,没有安装

2 执行脚本,安装 nvidia-docker
root@test:~# cat install-nvidia-docker.sh
sudo curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
sudo 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
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd
root@test:~#

检查 nvidia-dockernvidia-container-runtim 是否安装成功

root@test:~# which nvidia-docker
/usr/bin/nvidia-docker
root@test:~# which nvidia-container-runtime
/usr/bin/nvidia-container-runtime
root@test:~#
3 编辑 /etc/docker/daemon.json 内容如下
root@test:~# cat /etc/docker/daemon.json
{
  "insecure-registries": ["registry.test.cn"],
  "max-concurrent-downloads": 10,
  "log-driver": "json-file",
  "log-level": "warn",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  },
  "live-restore": true,
  "metrics-addr": "0.0.0.0:9323",
  "default-runtime": "nvidia",
  "experimental": true,
    "runtimes": {
        "nvidia": {
            "path": "/usr/bin/nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}
root@test:~#
4 重启 docker
root@test:~# systemctl daemon-reload
root@test:~# systemctl restart docker
5 验证
root@test:~# docker run --runtime=nvidia -ti  -v $(pwd):/workspace -w /workspace -v /nfs:/nfs $@ --privileged -v /var/run/docker.sock:/var/run/docker.sock registry.test.cn/mla/cxx_toolchains:latest
root@c3a43f4564a8:/workspace#
root@c3a43f4564a8:/workspace# ls
root@c3a43f4564a8:/workspace# pwd
/workspace
root@c3a43f4564a8:/workspace#
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值