WSL – Adding Cuda & CuDNN to the Environment


After installing the CUDA toolkit and CuDNN to your WSL environment, you must tell the system where to find the files.

This is how:

#Add CUDA to PATH and LD_LIBRARY_PATH

export PATH=/usr/local/cuda-11.8/bin${PATH:+:${PATH}} >> ~/.bashrc
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} >> ~/.bashrc
source ~/.bashrc

#Verification

nvcc --version
cat /usr/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

If during the verification code nothing comes up, it means that your installation was not successful.

This assumes a CUDA 11.8 install, for (example) 12.4 simply change the numbers in code. 11.8 –> 12.4

Leave a Reply

Your email address will not be published. Required fields are marked *