Cuda-toolkit can't be installed on wsl2

I follow the official guide to install cuda-toolkit on wsl2

  1. check the wsl kernel version and windows10 version
  2. install nvidia driver
  3. copy the following command to my shell

    but when I finish, i try to use nvcc, it reports “Command ‘nvcc’ not found”

    So can anyone gives me some suggestions?

so what was the output of running sudo apt-get -y install cuda-toolkit-12-3 ?

It all depends on whether this step was successful or not.

I think cuda-toolkit was installed successfully. But somehow it doesn’t work :(

You could check if subdirectories like


have been created. If so, there should be bin and lib subdirectories inside. These need to be in the PATH and LD_LIBRARY_PATH environment variables respectively.

This can be done in your ~/.bashrc script (assuming your Linux is using bash) with commands like

export PATH=/usr/local/cuda-12.3/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib:$LD_LIBRARY_PATH


Thanks for your help! It turns out I just forgot to add “/usr/loca/cuda/bin” to $PATH.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.