• notice
  • Congratulations on the launch of the Sought Tech site

Docker starts the container using gpu could not select with capabilities: [[gpu]].

    When docker starts the container using gpu, it prompts an error: docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].

    My server system here is Ubuntu18.04, the problem is that nvidia-container-toolkit or nvidia-container-runtime (it contains nvidia-container-toolkit) is not installed. To install nvidia-container-toolkit, you need to add the nvidia-docker source. The operation is as follows:

root@testMC:~/# distribution=$(./etc/os-release;echo $ID$VERSION_ID)
root@testMC:~/# curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add
root@testMC:~/# curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia- docker.list
root@testMC:~/# apt-get update
root@testMC:~/# apt-get install nvidia-container-toolkit
#gpus option prompt
root@testMC:~/# $ docker run --help | grep -i gpus
      --gpus gpu-request GPU devices to add to the container ('all' to pass all GPUs)
#After installation, you can test nvidia-smi on the official CUDA image through the following command (either of the two can be used)
root@testMC:~/# docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
root@testMC:~/# docker run --gpus all --rm nvidia/cuda nvidia-smi
Status: Downloaded newer image for nvidia/cuda:latest

    After installation, use any of the above commands to test nvidia-smi on the official CUDA image. The image starts successfully and displays GPU information normally. You can specify how many GPUs to use or which GPU to use for work.
#Start a container that supports two GPUs
$ sudo docker run –gpus 2 nvidia/cuda nvidia-smi
#Specify a certain GPU to run the container
$ sudo docker run –gpus device=0 nvidia/cuda nvidia-smi


Technical otaku

Sought technology together

Related Topic


Leave a Reply