In an Ubuntu terminal, enter nvidia-smi
. If that fails, make sure your Nvidia drivers are up-to-date (current version: 511.23). Win10 version also needs to be at least 21H2 (Winkey + R then winver
in Windows to check version).
Install CUDA Toolkit 11.2
Current versions of TF use CUDA 11.2 and cuDNN 8.1. Tested build configurations Run the below commands in a terminal:
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.2.2/local_installers/cuda-repo-wsl-ubuntu-11-2-local_11.2.2-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-11-2-local_11.2.2-1_amd64.deb
sudo apt-key add /var/cuda-repo-wsl-ubuntu-11-2-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
Install cuDNN
Download cuDNN v8.1.1 Run the below commands in a terminal (change .tgz filename as needed):
tar -xzvf cudnn-11.2-linux-x64-v8.1.1.33.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
CUPTI ships with the CUDA Toolkit. Append its installation direction to the $LD_LIBRARY_PATH
environment variable:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda-11.2/lib64
Run below in terminal:
sudo apt update && sudo apt install python3-pip
Run below in terminal:
pip install tensorflow
Run below in terminal:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
Output should end with something like [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
. If output ends with only []
, the GPU is not detected.
Installing Tensorflow with GPU, CUDA and cuDNN in Ubuntu 20.04 - Medium GPU support | TensorFlow
Thanks alot it worked,