Add nvidia runtime to docker runtimes on windows WSL
Asked Answered
C

1

8

I want to add the nvidia runtime to my docker. Note that i am running windows 11. Docker Desktop v.4.24.2 on Windows integrated on WSL 2 NVIDIA Drivers 545.84

I installed everything as nvidia-container-toolkit and in the wsl that is running ubuntu 22.04 LTS I am able to run

docker run --gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -it --rm -v .:/app nvcr.io/nvidia/pytorch:22.07-py3

And it actually loads my GPU with everything it needs. I know this because i am able to execute inside a jupyter notebook

import torch
for i in range(torch.cuda.device_count()):
   print(torch.cuda.get_device_properties(i).name)

And it shows my GPU (RTX 2080 SUPER)

But if i want to use the flag --runtime=nvidia it says

docker: Error response from daemon: unknown or invalid runtime name: nvidia. See 'docker run --help'.

I want to use it inside a docker compose:

version: '3'
services:
  pytorch_container:
    image: nvcr.io/nvidia/pytorch:22.07-py3
    command: ["bash"]
    volumes:
      - .:/app
    runtime: nvidia
    ipc: host
    ulimits:
      memlock: -1
      stack: 67108864
    stdin_open: true
    tty: true

It doesnt run because it doesnt find the nvidia runtime

I already tried https://mcmap.net/q/563506/-add-nvidia-runtime-to-docker-runtimes and still nothing

Clown answered 19/10, 2023 at 11:54 Comment(2)
So i will answer my own question. As i said, I already tried adding in the /etc/docker/daemon.json : { "runtimes": { "nvidia": { "path": "/usr/bin/nvidia-container-runtime", "runtimeArgs": [] } } } But it looks like the Docker desktop on windows doesnt look there. I found the daemon json in the Docker Desktop Settings under Docker Engine. I added the entry manually there and now it loads the nvidia runtime I hope it helps someone elseClown
docs.nvidia.com/datacenter/cloud-native/container-toolkit/…Continuo
C
21

So i will answer my own question.

As i said, I already tried adding in the /etc/docker/daemon.json :

{
    "runtimes":{
        "nvidia":{
            "path":"/usr/bin/nvidia-container-runtime",
            "runtimeArgs":[
                
            ]
        }
    }
}

But it looks like the Docker desktop on windows doesnt look there. I found the daemon json in the Docker Desktop Settings under Docker Engine. I added the entry manually there and now it loads the nvidia runtime I hope it helps someone else

Clown answered 23/10, 2023 at 7:6 Comment(2)
yes , win10 wsl2 works wellSternmost
would that allow kubernetes for docker-desktop to run with gpu support?Ornery

© 2022 - 2024 — McMap. All rights reserved.