Site icon Machine Learning Projects

How to Install TensorFlow with Cuda and cuDNN support in Windows – 2023

Machine Learning Projects

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…

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

https://www.tensorflow.org/install/source_windows#gpu

Step 2 – Download the CUDA Toolkit

Download Link – https://developer.nvidia.com/cuda-11.2.2-download-archive

NOTE – There is no Windows 11 version for CUDA 11.2 that’s why I used Windows 10 version and it worked like charm 🙂

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

Step 3 – Download cuDNN

Download Link – https://developer.nvidia.com/rdp/cudnn-archive

Step 4 – Download Visual Studio 2019 Community.

Download Link – https://my.visualstudio.com/Downloads?PId=8228

Step 5 – Extracting and merging files

RESTART YOUR COMPUTER.

Step 6 – Check the successful installation of CUDA

Step 7 – Create a conda environment and install TensorFlow

conda create -n gpu python=3.9
conda activate gpu
pip install tensorflow-gpu
import tensorflow as tf

tf.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 (sess.run(c))

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 projectsdeep learning projectscomputer vision projectsNLP projectsFlask projects at machinelearningprojects.net

Exit mobile version