How to properly install CUDA and cuDNN on Windows to use TensorFlow with GPU support
- Python 3.9–3.11
- pip version 19.0 or higher for Linux (requires manylinux2014 support) and Windows. pip version 20.3 or higher for macOS.
- Windows Native Requires Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019
- NVIDIA® GPU drivers version 450.80.02 or higher.
- CUDA® Toolkit 11.8.
- cuDNN SDK 8.6.0.
-
Download GeForce Experience to update drivers
-
Download Microsoft Visual C++ drivers
-
Download Visual Studio and Visual Studio Code
-
Download CUDA Toolkit version -
11.8
or Lattest version (not recommended
) -
Download cuDNN
v8.9.7
for CUDAv11.8.0
: -
Download NVIDIA Nsight Developer Tools:
-
Open the downloaded file
cuda_11.8.0_522.06_windows.exe
and follow the installation instructions.In the options select
express installation
-
Unzip the archive
cudnn-windows-x86_64-8.9.7.29_cuda11-archive.zip
and move with replace all files in thelib
,include
andbin
folders onC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8
with files from the corresponding archive folders:Add the following lines to your system and user
$Path
variable:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\include C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\lib C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\lib\x64
-
Install all the NVIDIA Nsight developer tools that we downloaded earlier
-
nvcc --version # Shows CUDA version
nvidia-smi # Shows the NVIDIA system management interface
Caution: TensorFlow 2.10 was the last TensorFlow release that supported GPU on native-Windows. Starting with TensorFlow 2.11, you will need to install TensorFlow in WSL2, or install tensorflow or tensorflow-cpu and, optionally, try the TensorFlow-DirectML-Plugin`
# Upgrade pip to latest version python -m pip install --upgrade pip # Anything above 2.10 is not supported on the GPU on Windows Native python -m pip install "tensorflow<2.11" # Verify the installation: python -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.
# If a tensor is returned, you've installed TensorFlow successfully. python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
🎉 Thank you for your attention! 🎉