Unable to find the kernel source tree for the current running kernel error when trying to install cuda toolkit on WSL2-ubuntu

Hi, I have a win10 PC with GTX1660Ti GPU. I am using a WSL2-Ubuntu 20.04 subsystem and I have the 470.14_gameready_win10-dch_64bit_international NVIDIA driver installed on my main system. I am attempting to install cuda toolkit using the following commands as recommended on the NVIDIA webpage.

wget https://developer.download.nvidia.com/compute/cuda/11.3.1/local_installers/cuda_11.3.1_465.19.01_linux.run
sudo sh cuda_11.3.1_465.19.01_linux.run

The installation failed with “Unable to find the kernel source tree for the current running kernel” error in the nvidia-installer.log file. How can I resolve this problem? Thanks!

2 Likes

Was there ever any solution to this? I’m in the same boat almost, but I have ubuntu 18.04

The install here is attempting to install the GPU driver, and that is why the kernel source issue arises. However that is not the correct way to install CUDA on WSL2. The GPU driver must not be installed on the WSL2 side. Please follow the WSL2 install instructions carefully.