I used to have a working CUDA environment on my wsl2 ubuntu 20.04 box, but after trying to install tensorflow, something broke.
My Windows build is 21327.1010, windows nvidia driver version is 470.05 and I did reinstall cuda 11.2 (from the .run file without installing the native driver).
deviceQuery returns with
cudaGetDeviceCount returned 35
→ CUDA driver version is insufficient for CUDA runtime version
Result = FAIL
Running strace, I can confirm that deviceQuery looks for for libcuda in /usr/lib/wsl/lib, but it fails to open
/dev/dxg, which does not exist anymore in my wsl system.
output from dmesg |grep dxg gives the following:
[ 7.557913] dxgk:err: dxg_drv_init Version: 5
[ 7.557917] hv_vmbus: registering driver dxgkrnl
If I reinstall the driver ( 470.05_gameready_win10-dch_64bit_international.exe) from the windows system, while the wsl box is open, /dev/dxg reappears and deviceQuery works (as well as any other CUDA application).
But after rebooting the host system, /dev/dxg is gone again.
I suspect it is caused by issues with this windows build - 21327 - more discussion of this here:
https://github.com/microsoft/WSL/issues/6617