No GPUs are available in WSL2+Pytorch on Windows 10 (21H2)

I’m using WSL2 on Windows 10 with Dell Precision 7760 which has a RTX A5000 where Driver Version 510.06 is installed.

I setup the environment referring the guide:

I’m using the latest version of Docker Desktop 4.4.4 (73704). The container initiated as follows:
docker run --gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -v /home/masa:/root -it --rm -p 8888:8888

The linux kernel in WSL2 is t.10.60 (the latest version as the time written)

When I check if GPU is available in the container with


it returns False with the following error messages.

/opt/conda/lib/python3.8/site-packages/torch/cuda/ UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 103: integrity checks failed (Triggered internally at  /opt/pytorch/pytorch/c10/cuda/CUDAFunctions.cpp:112.)
  return torch._C._cuda_getDeviceCount() > 0

Does anybody know how to fix this issue to access GPU in WSL2?

1 Like

I turn on the Windows Insider Program and joined in the beta channel.

Then it worked as expected.

But my computer will be upgraded to Windows 11… OHG