Cuda Toolkit on Ubuntu WSL

https://developer.nvidia.com/cuda-downloads?target_os=Linux

Uninstall all linux distributions.
Uninstall WSL (right-click on the windows start logo> App and Features> Enable or disable windows features> uncheck the box for Windows Subsystem for Linux).
Restart the computer.
Open PowerShell in administrator mode and perform the simplified installation of WSL, as it already (i) enables the optional WSL and Virtual Machine Platform components, (ii) downloads and installs the latest Linux kernel, (iii) defines WSL 2 as the default and (iv) download and install an Ubuntu distribution (Just to inform you, I had previously performed the manual installation):

PS C:\Users\sanam> wsl.exe –install
PS C:\Users\sanam> exit

Restart your computer, and wait while Ubuntu boots.
Within Ubuntu, enter the new user account and password.
Run the commands for installing and configuring the CUDA Toolkit:

$ sudo su

Enter your password to have root access and update Ubuntu.

/home/san# apt update
/home/san# apt upgrade

Then, follow the CUDA Toolkit Documentation > CUDA on WSL tutorial at https://docs.nvidia.com/cuda/wsl-user-guide/index.html 26, which is the same as the video “GPU Accelerated Machine Learning with WSL 2 “from Youtube:

/home/san# apt-key adv –fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub 9

/home/san# sh -c ‘echo “deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 6 /”> /etc/apt/sources.list.d/cuda.list’

/home/san# apt-get update

/home/san# apt-get install -y cuda-toolkit-11-0

Running a CUDA application:

/home/san# cd /usr/local /cuda/samples/4_Finance/BlackScholes

/usr/local /cuda/samples/4_Finance/BlackScholes# make

/usr/local /cuda/samples/4_Finance/BlackScholes# ./BlackScholes