'Window docker is not picking cuda on WSL2

I have installed Ubuntu 20.04.2 LTS on windows 11 (OS build 22000.100) using WSL2. When I do nvidia-smi, it shows me GPU. But when I run the docker image it gave the following error

RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx

I am using docker windows on wsl2. When I do uname -r i got 5.10.43.3-microsoft-standard-WSL2

Is there any solution?



Solution 1:[1]

Ensure you have the supported driver (https://developer.nvidia.com/cuda/wsl/download, free registration required), update Docker Desktop to the latest version, and then run docker run --rm -it --gpus=all nvcr.io/nvidia/k8s/cuda-sample:nbody to test it out. You then have to run your containers with --gpus=all.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jan Pokorný