Install TensorFlow with GPU Support on Windows 10

Current TensorFlow releases do not provide native-Windows GPU support. TensorFlow 2.10 was the final release that supported an NVIDIA GPU directly on native Windows. For TensorFlow 2.11 and later, the supported Windows route is Windows Subsystem for Linux 2 (WSL2).

This tutorial first explains the current WSL2 installation method. It then preserves the older native-Windows procedure for projects that must reproduce a legacy TensorFlow 1.x environment with Python 3.5, CUDA 9.0, and cuDNN 7.0.

Choose the Correct TensorFlow GPU Installation Route

Windows configurationTensorFlow GPU routePackage
Windows 10 with a current TensorFlow releaseRun TensorFlow inside WSL2tensorflow[and-cuda]
Native Windows with TensorFlow 2.10Use the version-matched legacy CUDA and cuDNN stacktensorflow<2.11
Native Windows with TensorFlow 2.11 or laterGPU execution is not officially supported; use WSL2 or install a CPU buildtensorflow
Historical TensorFlow 1.x projectReproduce the exact Python, CUDA, cuDNN, and TensorFlow versions required by the projectVersion-specific legacy package

Do not mix installation instructions from different TensorFlow releases. Python, TensorFlow, CUDA, cuDNN, the NVIDIA driver, and the operating environment must be compatible with one another. Check the current requirements in the official TensorFlow pip installation guide before selecting versions.

Install Current TensorFlow GPU Support through WSL2

The WSL2 route requires a supported 64-bit Windows 10 installation, an NVIDIA GPU supported by the current TensorFlow package, and an NVIDIA Windows driver that supports CUDA in WSL. The official TensorFlow instructions currently specify Windows 10 build 19044 or later for WSL2 GPU access.

Check the Windows 10 Build and NVIDIA GPU

Run winver from the Windows Start menu or Run dialog to check the Windows version and OS build. Update Windows before continuing if the installed build does not meet the current WSL2 requirement.

Open PowerShell or Command Prompt and verify that the NVIDIA driver recognizes the GPU:

</>
Copy
nvidia-smi

If this command fails on Windows, install or update the appropriate NVIDIA Windows driver before configuring TensorFlow. For WSL2, install the Windows NVIDIA driver; do not install a separate Linux display driver inside the WSL distribution.

Enable WSL2 and Install Ubuntu on Windows 10

Open PowerShell as an administrator and run:

</>
Copy
wsl --install

Restart Windows if prompted. Complete the Linux username and password setup when the installed distribution starts. If WSL is already installed, inspect its distributions and versions with:

</>
Copy
wsl --list --verbose

The Linux distribution used for TensorFlow should show version 2. If necessary, replace Ubuntu below with the exact distribution name reported by the preceding command:

</>
Copy
wsl --set-version Ubuntu 2

Verify NVIDIA GPU Access inside WSL2

Open the Ubuntu terminal and run nvidia-smi again:

</>
Copy
nvidia-smi

The output should identify the NVIDIA GPU and driver. Resolve driver or WSL GPU-access problems before installing TensorFlow; a Python package installation cannot correct a GPU that is unavailable to WSL2.

Create a Python Virtual Environment for TensorFlow in WSL2

Inside Ubuntu, install the Python virtual-environment and pip components:

</>
Copy
sudo apt update
sudo apt install python3-venv python3-pip

Create and activate an isolated environment named tf:

</>
Copy
python3 -m venv tf
source tf/bin/activate
python -m pip install --upgrade pip

Activate this environment whenever you work with the installed TensorFlow package. A virtual environment prevents packages required by one project from changing the dependencies used by another project.

Install the TensorFlow GPU Package with pip

With the virtual environment active, install TensorFlow and the NVIDIA CUDA dependencies provided through the GPU extra:

</>
Copy
python -m pip install "tensorflow[and-cuda]"

The package name for current releases is tensorflow. Do not use the discontinued tensorflow-gpu package for a new installation. The and-cuda extra installs the NVIDIA user-space dependencies expected by the supported TensorFlow package, but the compatible NVIDIA Windows driver must already be installed.

Verify TensorFlow and Detect the GPU in WSL2

Print the TensorFlow version and the physical GPU devices visible to TensorFlow:

</>
Copy
python -c "import tensorflow as tf; print(tf.__version__); print(tf.config.list_physical_devices('GPU'))"

A working GPU configuration returns a non-empty list containing a physical GPU device. An empty list means that TensorFlow imported successfully but did not detect a compatible GPU.

You can also run a small operation and display its assigned device:

</>
Copy
import tensorflow as tf

print("TensorFlow version:", tf.__version__)
print("GPUs:", tf.config.list_physical_devices("GPU"))

with tf.device("/GPU:0"):
    a = tf.random.normal((1000, 1000))
    b = tf.random.normal((1000, 1000))
    result = tf.matmul(a, b)

print(result.device)

The device string should include GPU:0. This confirms placement on the GPU; it does not measure whether the GPU is faster for a particular workload.

Use the TensorFlow GPU Environment in Jupyter Notebook

Install Jupyter and register the virtual environment as a kernel:

</>
Copy
python -m pip install jupyter ipykernel
python -m ipykernel install --user --name tensorflow-gpu --display-name "Python (TensorFlow GPU)"
jupyter notebook

In Jupyter, select Python (TensorFlow GPU) as the notebook kernel. Run tf.config.list_physical_devices('GPU') in a cell to confirm that the notebook uses the intended environment.

Legacy Native-Windows TensorFlow GPU Installation

The remaining procedure documents the original TensorFlow 1.x installation represented by the screenshots and code below. It uses Python 3.5, CUDA 9.0, cuDNN 7.0, and an NVIDIA GeForce GTX 1060. These versions should not be used for a new TensorFlow installation. They are retained for maintaining or reproducing an older project that explicitly requires this stack.

Install Python 3.5 for the Legacy TensorFlow Environment

Download the historical Python 3.5 installer from the following release page:

Link: https://www.python.org/downloads/release/python-350/

Under the Files section, select the installer matching the Windows architecture. Run the executable and select the option to add Python to PATH. Python 3.5 is obsolete, so isolate it from current Python projects and do not assume that modern TensorFlow packages will install into it.

Install CUDA 9.0 for Legacy Native Windows

CUDA 9.0 is a legacy release available from NVIDIA’s archive:

Link: https://developer.nvidia.com/cuda-90-download-archive

Select the appropriate operating system, Windows version, architecture, and local installer. Download the base installer and the patches required by the archived release. Install the base package first, followed by the patches in numerical order.

Install cuDNN 7.0 for CUDA 9.0

The original process required access to an NVIDIA Developer account.

Link : https://developer.nvidia.com/cudnn

The archived cuDNN 7.0 package for CUDA 9.0 is available at https://developer.nvidia.com/rdp/cudnn-archive#a-collapse705-9.

The associated archived installation guide is at https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.0.5/prod/Doc/cuDNN-Installation-Guide.

Follow the Windows instructions for that archived cuDNN release. The manual procedure places the cuDNN header, library, and binary files into the corresponding directories of the CUDA Toolkit installation. Do not copy these legacy libraries into a current CUDA installation.

Install the Historical tensorflow-gpu Package

The original tutorial used the following command after installing Python 3.5, CUDA 9.0, and cuDNN 7.0. It is preserved unchanged as a historical command:

$ pip3 install --upgrade tensorflow-gpu

The standalone tensorflow-gpu package is not the correct package for a current TensorFlow installation. A reproducible legacy setup should pin the exact TensorFlow version compatible with Python 3.5, CUDA 9.0, and cuDNN 7.0 instead of requesting an unspecified upgrade.

Install TensorFlow for GPU

Verify the Legacy TensorFlow 1.x Session

The following verification code uses the TensorFlow 1.x graph-and-session API. It is preserved unchanged for the historical environment and is not valid as written under the default TensorFlow 2.x execution model.

</>
Copy
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
TensorFlow Installation for GPU - Verification

In the historical output, the TensorFlow session initialization messages identify the physical NVIDIA GeForce GTX 1060. For TensorFlow 2.x, use tf.config.list_physical_devices('GPU') instead of creating a tf.Session.

Troubleshoot TensorFlow GPU Detection on Windows

TensorFlow Returns an Empty GPU Device List

  • Run nvidia-smi in both Windows and WSL2. The GPU must be visible at both levels.
  • Confirm that the Python command runs inside the virtual environment where tensorflow[and-cuda] was installed.
  • Check whether the installed TensorFlow release supports the selected Python version and GPU architecture.
  • Remove conflicting CUDA library paths from the WSL environment instead of combining unrelated system and pip-provided CUDA versions.
  • Restart WSL with wsl --shutdown from Windows after updating the NVIDIA driver, and then open the distribution again.

pip Cannot Find a Compatible TensorFlow Package

This error commonly indicates an unsupported Python version, operating-system architecture, or TensorFlow version constraint. Check the active interpreter and pip before installing:

</>
Copy
python --version
python -m pip --version
python -c "import platform; print(platform.architecture())"

Use python -m pip so that pip installs into the same interpreter used to run TensorFlow. Consult the official compatibility information before pinning an older TensorFlow version.

TensorFlow Loads CUDA Libraries from Conflicting Locations

Conflicts can occur when libraries installed by the TensorFlow GPU extra are mixed with incompatible CUDA or cuDNN files installed elsewhere. Review environment variables and package versions, and keep each TensorFlow project in its own virtual environment. Do not reuse CUDA 9.0 or cuDNN 7.0 files in a current WSL2 installation.

TensorFlow GPU Installation QA Checklist

  • Confirm that the tutorial route matches either current WSL2 TensorFlow or a specifically pinned native-Windows legacy release.
  • Verify the Windows build, WSL version, Python version, TensorFlow version, GPU model, and NVIDIA driver before documenting the result.
  • Run nvidia-smi inside WSL2 and record whether it identifies the intended GPU.
  • Run tf.config.list_physical_devices('GPU') and confirm that the returned list is not empty.
  • Check that installation commands use tensorflow[and-cuda] for current WSL2 instructions rather than the discontinued tensorflow-gpu package.
  • Ensure Jupyter uses the registered TensorFlow virtual-environment kernel rather than a different Python interpreter.
  • Keep legacy Python 3.5, CUDA 9.0, cuDNN 7.0, and TensorFlow 1.x instructions clearly separated from the current installation path.

Frequently Asked Questions About TensorFlow GPU on Windows

Can current TensorFlow use an NVIDIA GPU directly on native Windows?

No. TensorFlow 2.10 was the last release with native-Windows GPU support. TensorFlow 2.11 and later require WSL2 for the officially supported NVIDIA GPU route on Windows.

Should I install tensorflow-gpu with pip?

Not for a current installation. Use the tensorflow package. For current GPU support in WSL2, the official pip instructions use tensorflow[and-cuda]. The old tensorflow-gpu name belongs to earlier installation workflows.

Do I need to install CUDA and cuDNN manually for TensorFlow in WSL2?

The current tensorflow[and-cuda] installation route supplies the required NVIDIA user-space dependencies through pip. You still need a compatible NVIDIA Windows driver with WSL support. Follow the version requirements in the current TensorFlow documentation.

How can I confirm that TensorFlow is using the GPU?

Run tf.config.list_physical_devices('GPU'). A non-empty list confirms that TensorFlow detects a GPU. For an individual tensor or operation, inspect its device property to confirm placement on GPU:0.

Why does TensorFlow detect the GPU in a terminal but not in Jupyter?

Jupyter is probably using a different Python environment. Install ipykernel inside the TensorFlow virtual environment, register it as a kernel, and select that kernel in the notebook before testing GPU detection.

TensorFlow GPU Installation Summary

For current Windows 10 systems, install TensorFlow GPU support inside WSL2, use an isolated Python environment, install tensorflow[and-cuda], and verify the result with tf.config.list_physical_devices('GPU'). Use the native-Windows Python 3.5, CUDA 9.0, cuDNN 7.0, and tensorflow-gpu procedure only when maintaining a compatible legacy project. In this Deep Learning Tutorial, both routes are kept separate so their dependencies are not mixed.