acces gpu thru docker

Installing NVIDIA Container Runtime

curl -s -L | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L$distribution/nvidia-container-runtime.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo apt-get update
sudo apt-get install nvidia-container-runtime

add to docker

add it to docker runtimes

sudo tee /etc/docker/daemon.json <<EOF
    "runtimes": {
        "nvidia": {
            "path": "/usr/bin/nvidia-container-runtime",
            "runtimeArgs": []
sudo systemctl daemon-reload
sudo systemctl restart docker.service

and / or

sudo systemctl edit docker.service
ExecStart=/usr/bin/dockerd --add-runtime=nvidia=/usr/bin/nvidia-container-runtime

install driver

sudo apt install nvidia-utils-525-server
sudo apt install nvidia-driver-525 nvidia-dkms-525

Leave a Comment