Set up Windows Subsystem for Linux (version 2) with CUDA support + TensorFlow.
- You must be on Windows 10 21H2 or above.
Note: On my system 21H2 could not be updated to. I ended up with a bricked install as Windows tried to install Windows 11 on my unsupported CPU. I recommend just installing Windows 10 21H2 directly from an ISO.
- You don't have to be on OS build 20140 or above as some sources state. My build: 19044.1469
- Install the latest "game ready driver" for your card.
Note: You don't need a special driver despite the Nvidia documentation, I got mine here: https://www.nvidia.com/Download/index.aspx
- The
apt-cache search <PACKAGE>
command is your friend. Use it to see what CUDA versions are available.
-
Open CMD as administrator and run:
wsl --install -d ubuntu
-
In the Ubuntu WSL, update the system:
sudo apt update sudo apt upgrade
-
Install Git:
sudo apt install git
-
Figure out what version of CUDA & cuDNN you need, I recommend looking at this page: https://www.tensorflow.org/install/source#gpu
-
Find the desired version of CUDA on this page: https://developer.nvidia.com/cuda-toolkit-archive
-
Enter the following information and follow the instructions, but do not run the
apt-get install cuda
command! -
Install the specific version of CUDA, for example:
sudo apt install cuda-toolkit-11-8 cuda-11-8
-
Install cuDNN for CUDA 11.x and Ubuntu 22.04:
- Download the TAR file from: https://developer.nvidia.com/rdp/cudnn-archive
- Decompress the file, for example:
tar xf cudnn-linux-x86_64-8.9.5.30_cuda11-archive.tar.xz
- Copy the library files into the right place:
cd cudnn-linux-x86_64-8.9.5.30_cuda11-archive/ sudo cp include/cudnn.h /usr/local/cuda-11/include/ sudo cp lib/libcudnn* /usr/local/cuda-11/lib64/ sudo chmod a+r /usr/local/cuda-11/include/cudnn.h /usr/local/cuda-11/lib64/libcudnn*
-
Edit
~/.bashrc
and add the following:# CUDA environment variables export PATH=/usr/local/cuda-11/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-11/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
-
Restart your terminal or run
source ~/.bashrc
-
Verify CUDA installation (optional)
git clone https://github.com/NVIDIA/cuda-samples.git cd cuda-samples/Samples/5_Domain_Specific/BlackScholes/ make ./BlackScholes
-
Install Python and Tensorflow (optional)
sudo apt install python3-dev python3-pip pip3 install tensorflow
-
Try not to think about https://en.wikipedia.org/wiki/Embrace,_extend,_and_extinguish (optional)