How to install Cuda and Cudnn for Deep Learning
By โข July 04, 2025
โ How I Successfully Installed TensorFlow with GPU Support on Windows (2025 Guide)
If you’ve ever struggled to get TensorFlow to detect your NVIDIA GPU on Windows — you’re not alone. I went through the same headache, but after fixing a few key mistakes, it finally worked. Here’s exactly what I did, step by step, including all the commands and setup process.
๐ฏ Goal
I wanted to set up TensorFlow 2.10 with GPU acceleration on my Windows laptop (RTX 4050 + i7 12th Gen). While regular CPU-based tasks were fine, I needed GPU power for deep learning. Unfortunately, it didn’t “just work” — and here’s what fixed it.
โ The Mistake I Made
Like many beginners, I installed CUDA 10.1 (the version I found online), assuming it would work. But TensorFlow is very specific about what versions it supports. I was using:
tensorflow 2.10.0
CUDA 10.1 โ (wrong!)
But for GPU to work, TensorFlow 2.10 requires:
-
CUDA 11.2
-
cuDNN 8.1
๐ง Fixing the Setup — Step by Step
โ 1. Uninstall Old CUDA
I couldn’t find CUDA 10.1 in my installed apps, so I deleted the folder manually:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
I also cleaned up old CUDA entries from my environment variables (more below).
โ 2. Install CUDA 11.2
Download from the official archive:
๐ CUDA 11.2.2 Download Link
Follow the installer, and make sure it's installed to:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2
โ 3. Install cuDNN 8.1
Download from the cuDNN archive (you’ll need an NVIDIA login):
๐ cuDNN v8.1.1 for CUDA 11.2
Unzip the files and copy them into the CUDA folder:
From cuDNN Folder | To CUDA Folder |
---|---|
bin\*.dll |
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin |
include\*.h |
...\include |
lib\x64\*.lib |
...\lib\x64 |
โ
I confirmed files like cudart64_110.dll
and cudnn64_8.dll
were present.
โ 4. Set Environment Variables
Go to:
Start → Environment Variables → Edit the system environment variables
In the System Path
, I added:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\libnvvp
And created a new User variable:
CUDA_PATH = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2
๐งน I also made sure no old CUDA (10.1) paths were left in the PATH.
๐ 5. Reboot Your System
This is critical. Skipping the reboot kept my old CUDA settings active. After reboot, the new ones took effect.
๐ Installing TensorFlow (Correct Way)
After CUDA and cuDNN were set up, I created a virtual environment for TensorFlow:
# Create and activate virtual environment
python -m venv tf_gpu
.\tf_gpu\Scripts\activate
# Install TensorFlow 2.10 (GPU support built-in)
pip install tensorflow==2.10.0
โ Note: TensorFlow 2.10 is the last version that supports native GPU on Windows.
โ Verifying GPU Support in Python
Now comes the fun part — testing if it works:
import tensorflow as tf
print("TensorFlow version:", tf.__version__)
print("GPU available:", tf.config.list_physical_devices('GPU'))
Output:
TensorFlow version: 2.10.0
GPU available: [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
๐ Optional: Check All Devices
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
๐งช Bonus: Force TensorFlow to Use GPU
tf.debugging.set_log_device_placement(True)
with tf.device('/GPU:0'):
a = tf.constant([[1.0, 2.0], [3.0, 4.0]])
b = tf.constant([[1.0, 1.0], [0.0, 1.0]])
c = tf.matmul(a, b)
print(c)
๐ง What I Learned
-
TensorFlow is very strict about CUDA/cuDNN versions.
-
Even if the files are installed correctly, old paths in the environment variables can silently break everything.
-
Rebooting is non-negotiable — DLLs don’t refresh until a restart.
-
The TensorFlow + GPU setup on Windows works perfectly, but only with the exact supported versions.
๐ Useful Links