Cannot use cuda after uninstall old version on my wsl2,the program report cannot find drivers

I try to remove the old cuda version and install the newest version on wsl.
I updated the nvidia driver on my windows,and use runfile to install cuda toolkit(wsl-ubuntu ver.) on wsl.
but when I tried to compile my cuda program,nvcc report that `no cuda capable device is detected,
and program cannot communicate with NVIDIA driver.
I heard wsl need not to install a driver,so how can i work out it?

Hello,

A quick sanity check will be to look for the WSL folders on your WSL distribution: /lib/wsl/lib and /lib/wsl/drivers. And checking as well for /dev/dxg.

If those folders and files are present, then the likely issue is that there might be still a native linux driver on the system taking precedence.

Otherwise, if those folders and files are not present then there might be some issue with the GPU enablement part of WSL. In this case make sure that:

  • You are using WSL2 for that specific distribution and not WSL (You can run wsl -l -v on the Windows host in Powershell)
  • WSL is up to date. (You can run wsl --update to check for the latest subsystem updates)
  • WSL GPU support is supported by your current Windows version. (You need either Windows 11 or Windows 10 version 21H2)

Let us know how it goes,
Thanks !

I find the folders /lib/wsl/lib and /liv/wsl/driver but no /dev/dxg.
And the privious two are also present in a new installation of wsl2. Is there a defaut installation of vedio card driver installed on a new ms store version wsl2 installation?

My wsl2 with wslg is in the most recent version,and my host system is win11

i try to use sudo apt-get --purge remove nvidia* to reinstall the cuda toolkit by the runfile(wsl ver) but still not go.


and it’s what be reported after run the runfile.

it’s now work out.Use dpkg -l | grep -i nvidia to find out some removed pkgs with unremoved file (rc) and use dkpg -P to clean the rest file.
thanks to https://blog.csdn.net/weixin_42563415/article/details/116805068