docker: Error response from daemon: could not select device driver ““ with capabilities: [[gpu]]问题解决

问题出现

我们知道,想要在 docker19 及之后的版本中使用 nvidia gpu 已经不需要单独安装 nvidia-docker 了,这已经被集成到了 docker 中。

相必大家也知道,要使用宿主机的 GPU,需要在 docker run 的时候添加 --gpus [xxx] 参数。

但是,在我们刚刚安装好 docker 并构建好镜像之后,直接这样运行是有问题的,即:

docker run -it --gpus all image_name:tag_name

会出现如题报错:

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

解决方案

实际上,我们在通过 --gpus 参数来使用宿主机的 GPU 时,需要先安装一个英伟达的容器运行。

另外需要注意的是,这个东西是不能直接 apt install,会报找不到该软件,需要先添加英伟达的 apt 软件源。具体操作步骤如下:

1 添加源

将下面的脚本放到任意位置,

# nvidia-container-runtime-script.sh

sudo curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
su

猜你喜欢

转载自blog.csdn.net/JineD/article/details/129539977