Chanakya AI Intelligent Solutions for a Smarter Future

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:


๐Ÿ”ง 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


๐Ÿ”— Useful Links