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

需要安装nvidia-container-toolkitnvidia-container-runtime(包含nvidia-container-toolkit)

distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - 
#正常会显示OK
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list 我的系统是Ubuntu18.04
sudo apt-get update 
#这一步要保证没得问题,我的显示有几个源重复配置,然后我就将其(sudo vim nvidia-docker.list)注释掉
sudo apt-get install nvidia-container-toolkit
sudo systemctl restart docker

重启docker后成功!

docker run -it --rm --gpus all ubuntu nvidia-smi -L
GPU 0: NVIDIA GeForce MX350 (UUID: GPU-xxxxxxxxxxxxxxxxxx)

参考docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]. - 巴蜀秀才 - 博客园

如果是WSL2可参考官方教程:

Install Nvidia Container Toolkit

Set the distribution variable, import the Nvidia repository GPG key, and then add the Nvidia repositories to the Ubuntu apt package manager:

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

curl -s -L https://nvidia.github.io/libnvidia-container/experimental/$distribution/libnvidia-container-experimental.list | sudo tee /etc/apt/sources.list.d/libnvidia-container-experimental.list

docker: Error response from daemon: could not select device driver ““ with capabilities: [[gpu]]._第1张图片

Refresh the Ubuntu apt repositories and then install the Nvidia runtime:

sudo apt update && sudo apt install -y nvidia-docker2

docker: Error response from daemon: could not select device driver ““ with capabilities: [[gpu]]._第2张图片

Close all open terminals of Ubuntu, open a PowerShell terminal, and manually shutdown Ubuntu:

wsl.exe --shutdown Ubuntu

Open a new Ubuntu terminal and start Docker:

sudo service docker stop


重新启动试试。

你可能感兴趣的:(Ubuntu和git(WSL),docker,容器,ubuntu)