Windows OS

How to Install TensorFlow with Native NVIDIA GPU/CUDA Acceleration on Windows 10/11

The TensorFlow version that is newer than 2.10.1 dropped its support for native NVIDIA GPU/CUDA acceleration on the Windows 10/11 operating system. The latest version of TensorFlow supports the NVIDIA GPU/CUDA acceleration via WSL only. So, if you want to run the TensorFlow AI/ML codes with native NVIDIA GPU/CUDA acceleration on Windows 10/11, you have to install an older version of TensorFlow on your computer.

In this article, we will show you how to install TensorFlow with the native NVIDIA GPU/CUDA acceleration on Windows 10/11 operating systems.

Topic of Contents:

  1. Installing the NVIDIA GPU Drivers on Windows 10/11
  2. Installing NVIDIA CUDA and CuDNN on Windows 10/11
  3. Installing Python on Windows 10/11
  4. Installing TensorFlow on Windows 10/11
  5. Checking If TensorFlow Is Installed Correctly on Windows 10/11
  6. Checking If TensorFlow Can Use the GPU/CUDA Acceleration on Windows 10/11
  7. Checking If TensorFlow Can Use the NVIDIA CuDNN Library on Windows 10/11
  8. Conclusion

Installing the NVIDIA GPU Drivers on Windows 10/11

For the TensorFlow native NVIDIA GPU/CUDA acceleration to work on Windows 10/11, you must have an NVIDIA GPU installed on your computer and install the NVIDIA GPU driver on Windows 10/11. If you have an NVIDIA GPU installed on your computer and you need any assistance in installing the NVIDIA GPU driver on Windows 10/11, read this article.

Installing NVIDIA CUDA and cuDNN on Windows 10/11

Once you installed the NVIDIA GPU drivers on your Windows 10/11 system, you have to install NVIDIA CUDA and NVIDIA cuDNN for the TensorFlow native NVIDIA GPU/CUDA acceleration to work.

If you need any assistance in installing NVIDIA CUDA on your Windows 10/11 operating system, read this article.

If you need any assistance in installing NVIDIA cuDNN on your Windows 10/11 operating system, read this article.

Installing Python on Windows 10/11

TensorFlow 2.10 requires Python 3.10 to work. If you have the newer versions of Python (newer than Python 3.10) installed on your Windows 10/11 system, you must uninstall it and install Python 3.10 for TensorFlow 2.10 to work.

If you need any assistance in uninstalling Python from Windows 10/11 to install Python 3.10, read this article.

If you need any assistance in downloading and installing Python 3.10 on Windows 10/11, read this article.

You can also install TensorFlow 2.10 if you’re using Anaconda Python and get the native NVIDIA GPU/CUDA acceleration to work. In that case, you have to create an Anaconda Python 3.10 virtual environment. To learn how to create an Anaconda Python 3.10 virtual environment, read this article.

If you don’t have the Anaconda Python installed on your Windows 10/11 system and you would like to install it, read this article.

Installing TensorFlow on Windows 10/11

Before you install TensorFlow on Windows, open a Terminal and check if you’re using Python 3.10.x and you have access to Python PIP.

$ python --version
$ pip --version

If you’re using Python 3.10.x and you have access to the Python PIP package manager, install TensorFlow 2.10.1 with the following command:

$ pip install tensorflow==2.10.1

TensorFlow 2.10.1 is being installed. It takes a while to complete.

At this point, TensorFlow 2.10.1 should be installed.

Checking If TensorFlow Is Installed Correctly on Windows 10/11

Once TensorFlow 2.10.1 is installed, run the following command to check whether you can access it on your Windows 10/11 operating system:

$ python -c 'import tensorflow; print(tensorflow.__version__)'

If TensorFlow 2.10.1 is installed correctly and you can access it, the previous command should print the TensorFlow version number 2.10.1 as you can see in the following screenshot:

Checking If TensorFlow Can Use the GPU/CUDA Acceleration on Windows 10/11

To learn how to check whether TensorFlow can use the GPU/CUDA acceleration natively on your Windows 10/11 operating system, read this article.

Checking If TensorFlow Can Use the NVIDIA CuDNN Library on Windows 10/11

To learn how to check whether TensorFlow can use the NVIDIA cuDNN library on your Windows 10/11 system, read this article.

Conclusion

The TensorFlow version that is newer than 2.10.1 dropped its support for the native NVIDIA GPU/CUDA acceleration for Windows operating systems. So, to get the native NVIDIA GPU/CUDA acceleration support on Windows, you must install the TensorFlow version 2.10.1 which also requires the Python version 3.10.x to work. In this article, we showed you how to install TensorFlow 2.10.1 on Windows 10/11 operating systems so that TensorFlow can use the NVIDIA GPU/CUDA acceleration natively to speed up the AI/ML training.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.