使docker容器能调用本地的gpu

70次阅读
没有评论

问题复现

执行命令:docker run -it –gpus all nvidia/cuda:10.1-cudnn8-devel-centos7 /bin/bash

报错:docker: Error response from daemon: could not select device driver “” with capabilities: [[gpu]].

解决方案

方案1:安装nvidia-docker,该方法已被官方舍弃

方案2:安装nvidia-container-toolkit,又名nvidia-docker2,后添加—gpus参数来使用

方案3:安装nvidia-container-runtime,在首次运行时添加—runtime=nvidia参数,后续启动、结束都不需要再加。

最后重启 docker生效:systemctl restart docker

使用nvidia-container-toolkit

distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo

yum install -y nvidia-container-toolkit

使用nvidia-container-runtime

distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo

yum install -y nvidia-container-runtime

正文完
 
评论(没有评论)