CUDA error: all CUDA-capable devices are busy or unavailable

Hi, I am having the same issue described here: https://github.com/microsoft/WSL/issues/5598

In summary: Although torch is able to find CUDA, and nothing else is using the GPU, I get the error “all CUDA-capable devices are busy or unavailable”

Windows 10, Insider Build 20226
NVIDIA driver 460.20
WSL 2 kernel version 4.19.128

Python:
import torch
torch.cuda.is_available()
> True
torch.randn(5)
> tensor([-2.6408, -1.0831, -1.6984, 0.4742, -0.5909])
torch.randn(5).to(2)
> Traceback (most recent call last):
> File “”, line 1, in
> RuntimeError: CUDA error: all CUDA-capable devices are busy or unavailable

deviceQuery:
./deviceQuery
./deviceQuery Starting…

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: “GeForce RTX 2080 with Max-Q Design”
CUDA Driver Version / Runtime Version 11.2 / 11.0
CUDA Capability Major/Minor version number: 7.5
Total amount of global memory: 8192 MBytes (8589934592 bytes)
(46) Multiprocessors, ( 64) CUDA Cores/MP: 2944 CUDA Cores
GPU Max Clock rate: 1095 MHz (1.10 GHz)
Memory Clock rate: 6001 Mhz
Memory Bus Width: 256-bit
L2 Cache Size: 4194304 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 1024
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 2 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Device supports Managed Memory: Yes
Device supports Compute Preemption: Yes
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: Yes
Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.2, CUDA Runtime Version = 11.0, NumDevs = 1
Result = PASS

The same issue occurs with Tensorflow nightly, the latest windows update seems to have broken compatibility between WSL2 and CUDA. Any interaction with CUDA seems to crash, including checking GPU availability.

I have rolled back to 20201 and everything works, including other CUDA versions. See WSL2 & CUDA does not work [v20226] · Issue #6014 · microsoft/WSL · GitHub.

But when testing the nvidia-docker-2 I get this error:
docker: Error response from daemon: could not select device driver “” with capabilities: [[gpu]].
ERRO[0084] error waiting for container: context canceled

FYI, on the newest Windows Insider build, 20236, I am able to run CUDA on WSL. Both the minimal example import torch; torch.randn(1).to(0) and training a pytorch model work on GPU.

With the latest 20257.1 the nvidia docker fails again

I have same problem but in Ubuntu. I partitioned SDD and so I have two OS installed.(windows n ubuntu)
Can I get some advice?
I cannot find “busy or unavailable” error in same situation as mine.