CUDA on WSL

Back to Index

I like to create a directory to keep everything organized, so in Ubuntu terminal (WSL, I mean), type:

  • cd ~
  • mkdir Cuda
  • cd Cuda

Now, go back to CUDA downloads and choose:

Linux   >   x86_64   >   WSL-Ubuntu   >   2.0   >   deb (local)

I prefer deb (local) because the internet connection will not get in your way during the installation.

The steps I see are:

  • wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
  • sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
  • wget https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda-repo-wsl-ubuntu-11-3-local_11.3.0-1_amd64.deb
  • sudo dpkg -i cuda-repo-wsl-ubuntu-11-3-local_11.3.0-1_amd64.deb
  • sudo apt-key add /var/cuda-repo-wsl-ubuntu-11-3-local/7fa2af80.pub
  • sudo apt-get update
  • sudo apt-get -y install cuda

I usually don't set -y in sudo apt-get install, because I like to see what will be installed. Maybe there is a package with the wrong version ready to cause a conflict later.


After the installation, check if there is any cuda library in /usr/lib/wsl/lib. Again, if this directory does not exists, something is wrong with your WSL installation. But if you found them, then it is time for testing if the GPU is visible.

Download the CUDA samples via GIT:
  • git clone https://github.com/NVIDIA/cuda-samples.git
  • cd cuda-samples/Samples/deviceQuery
  • make 
  • ./deviceQuery
You may want to check this last command sometimes. When I installed it in my desktop, the version I saw was:
  • CUDA Driver Version / Runtime Version          11.3 / 11.2
Now it is:
  • CUDA Driver Version / Runtime Version          11.4 / 11.2
 As you can see, when the driver in Windows is updated, WSL know it too.


<- Back 

Next ->

No comments:

Post a Comment

Global Game Jam 2024

Wow, what a weekend. The Global Game Jam is intense. But I and 3 other members manage to build a game for the theme "Make me laugh&quo...