Issue
I am trying install Cuda on WSL 2. I am following instructions such as this.
After executing every step, I try to check if gpu is available in the Linux environment by executing docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
(as suggested by the aforementioned instructions).
But I get the following error:
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
ERRO[0000] error waiting for container: context canceled
.
Any ideas what might be the cause of this?
Solution
I was having the same issue. Are you using Docker Desktop for Windows? Because I was, and I found out that WSL2 + CUDA does not work with Docker Desktop for Windows:
https://forums.developer.nvidia.com/t/hiccups-setting-up-wsl2-cuda/128641
Instead, install Docker manually in WSL2 (as is suggested in the tutorial you linked):
sudo apt update && sudo apt install -y nvidia-docker2
Then make sure you start the docker service:
sudo service docker start
After that, you can verify the CUDA/Docker/WSL2 setup with this:
docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
Where you should see some output like this:
NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.
Windowed mode Simulation data stored in video memory Single precision floating point simulation 1 Devices used for simulation MapSMtoCores for SM 7.5 is undefined. Default to use 64 Cores/SM GPU Device 0: "GeForce RTX 2060" with compute capability 7.5
Compute 7.5 CUDA device: [GeForce RTX 2060] 30720 bodies, total time for 10 iterations: 52.181 ms = 180.854 billion interactions per second = 3617.077 single-precision GFLOP/s at 20 flops per interaction
Answered By - wlane Answer Checked By - Robin (WPSolving Admin)