- Install CUDA 11.8
$ 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.8.0/local_installers/cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
$ sudo dpkg -i cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
$ sudo cp /var/cuda-repo-wsl-ubuntu-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/
$ sudo apt-get update
$ sudo apt-get -y install cuda
- Install CUDNN 8.6.0 (Download from here first)
$ sudo apt-get install zlib1g
$ tar -xvf cudnn-linux-x86_64-8.6.0.163_cuda11-archive.tar.xz
$ sudo cp cudnn-*-archive/include/cudnn*.h /usr/local/cuda/include
$ sudo cp -P cudnn-*-archive/lib/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
- Run the command below in Windows Command Prompt as admin (Thanks to Roy Shilkrot) and restart your WSL2
> cd \Windows\System32\lxss\lib
> del libcuda.so
> del libcuda.so.1
> mklink libcuda.so libcuda.so.1.1
> mklink libcuda.so.1 libcuda.so.1.1
- Setup some WSL2 paths
$ echo 'export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
$ source ~/.bashrc
$ sudo ldconfig
- Update some dependencies
$ sudo apt update
$ sudo apt upgrade
- (Optional) Install Python 3.9.2 using pyenv
I used Python 3.9.2 for the exam, so I had to use pyenv in Ubuntu to not change Ubuntu's default Python. As for you, you can use Python 3.10.* and have no problem.
$ curl https://pyenv.run | bash
$ sudo apt install curl -y
$ sudo apt install git -y
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(pyenv init - --path)"' >> ~/.bashrc
$ exec $SHELL
$ sudo apt install build-essential curl libbz2-dev libffi-dev liblzma-dev libncursesw5-dev libreadline-dev libsqlite3-dev libssl-dev libxml2-dev libxmlsec1-dev llvm make tk-dev wget xz-utils zlib1g-dev
$ pyenv install 3.9.2
$ pyenv global 3.9.2
- Install TensorFlow 2.13
$ pip install --upgrade pip
$ pip install tensorflow==2.13
- Verify the GPU Setup
$ python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
If a list of GPU devices is returned, you've installed TensorFlow successfully.
Hello,
I contact you because i have this error when i use the command 'del libcuda.so' (i followed the steps like before):
Microsoft Windows [version 10.0.22621.1702]
(c) Microsoft Corporation. Tous droits réservés.
C:\Windows\System32>wsl
silvio@Silvio:/mnt/c/Windows/System32$ cd lxss
silvio@Silvio:/mnt/c/Windows/System32/lxss$ cd lib
silvio@Silvio:/mnt/c/Windows/System32/lxss/lib$ del libcuda.so
Command 'del' not found, did you mean:
command 'den' from snap den (1.2.0-0)
command 'mdel' from deb mtools (4.0.33-1+really4.0.32-1build1)
command 'el' from deb oneliner-el (0.3.6-9.1)
command 'qdel' from deb gridengine-client (8.1.9+dfsg-10build1)
command 'qdel' from deb slurm-wlm-torque (21.08.5-2ubuntu1)
command 'delv' from deb bind9-dnsutils (1:9.18.18-0ubuntu0.22.04.1)
command 'delp' from deb fp-utils-3.2.2 (3.2.2+dfsg-9ubuntu1)
command 'hdel' from deb hfsutils (3.2.6-15build2)
command 'dex' from deb dex (0.9.0-1)
command 'wdel' from deb wput (0.6.2+git20130413-11)
command 'dll' from deb brickos (0.9.0.dfsg-12.2)
command 'deal' from deb deal (3.1.9-12)
See 'snap info ' for additional versions.
Thx you if you have any ideas c;