How to Install TensorFlow with Cuda and cuDNN support in Windows

Abhishek Sharma
4 min readFeb 26, 2022


Hey guys, In this blog we will see how we can install Tensorflow with CUDA and cuDNN. This process can be really tricky and frustrating if you are doing it for the very first time. So without any further due, let’s do it…

Read the full blog with a detailed explanation here —

Checkout the video here —

Step 1 — Decide versions for CUDA,cuDNN, and Visual Studio

  • We will download the following versions.
  • CUDA 11.5
  • cuDNN 8.3
  • Microsoft Visual Studio 2019

Step 2 — Download CUDA Toolkit

Download Link —

Windows > x86_64 > 11 > exe(local) > Download

Step 3 — Download cuDNN

Download Link —

  • If you have an account on Nvidia simply Login otherwise click on Join Now.
  • We will sleect the latest version (8.3) for CUDA 11.5 and we will download the zip for Windows.

Step 4 — Download Visual Studio 2019 Community.

Download Link —

  • Login to Microsoft and then search Visual Studio 2019 and download the Community version.
  • It will download a setup.
  • Install that setup.
  • It will ask to download workloads, just skip it and just install Visual Studio Core Editor.

Step 5 — Extracting and merging files

  • Once you have successfully downloaded CUDA and cuDNN, install the CUDA toolkit by double-clicking on it.
  • Agree and Continue > Express (Recommended). It can restart while installation process.
  • Then extract the cuDNN zip. It will produce 4 files.
  • Copy these 4 files and paste them into C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.5 and replace the files in destination.
  • Now open the bin Folder and copy the path from address bar.
  • Now open the start menu and type env and you will see an option “Edit the System Environment Variables”. A window like below will popup.
  • Click on Environment Variables here.
  • In the user variables (in the top section) double click on Path and click New.
  • Now paste the bin path you copied in a new field and hit OK.
  • Now do the same steps for libnvvp folder also.
  • Copy the path to libnvvp folder and add a new record in path.


Step 6 — Check successful installation of CUDA

  • Run the nvidia-smi command in your terminal.
  • You can see in the top right corner, CUDA Version: 11.5

Step 7 — Create conda environment and install TensorFlow

  • Now open your terminal and create a new conda environment.
  • Use the following command and hit “y”.
  • Here gpu is the name that I given to my conda environment.
conda create -n gpu python=3.9
  • Activate the conda environment and install TensorFlow (gpu version).
conda activate gpu
pip install tensorflow-gpu
  • Now simply copy the code below and paste it into a file named
import tensorflow as tftf.compat.v1.disable_eager_execution()with tf.device('/gpu:0'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
with tf.compat.v1.Session() as sess:
print (
  • Now run the python file in the conda environment.
  • If you see these results, bingo!! we have successfully installed TensorFlow with CUDA and cuDNN support :)

So this is how you will install TensorFlow with Cuda and cuDNN in Windows, thanks for reading it and I hope you are taking something with you after reading this and till the next time 👋…

Check out my other machine learning projects, deep learning projects, computer vision projects, NLP projects, Flask projects at