Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
AI and LLM integration

pip install tensorflow-gpu fails, and Windows still trains on the CPU

Your error

The "tensorflow-gpu" package has been removed!2 more lines it can show

Fix it fast

Most common cause, 1 of 3

The install command or requirements file still says tensorflow-gpu

Swap tensorflow-gpu for tensorflow in every file and command.

Fix
python3 -m pip uninstall -y tensorflow-gpu
python3 -m pip install 'tensorflow[and-cuda]'
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

tensorflow-gpu was retired in December 2022, and its final 2.12.0 upload only raises an error during install, so install tensorflow instead. On native Windows that runs on the CPU: TensorFlow 2.10 was the last release with native-Windows GPU support. For a GPU, run tensorflow[and-cuda] inside WSL2, or pin tensorflow<2.11 on Python 3.10 or older.

  • Applies to TensorFlow 2.21.0 (Python 3.10 to 3.13), TensorFlow 2.10 for native-Windows GPU, WSL2 on Windows 10 21H2 (build 19044) or later
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Print the Python version and operating system, see which TensorFlow packages are installed, and ask TensorFlow for GPUs. These three answers point to one cause.

Run this first
python -c "import sys, platform; print(sys.version.split()[0], platform.system())"
python -m pip show tensorflow tensorflow-gpu
python -c "import tensorflow as tf; print(tf.__version__, tf.config.list_physical_devices('GPU'))"

Then find the line you see in this list and open its fix:

  1. 1The install command or requirements file still says tensorflow-gpupip fails while preparing tensorflow-gpu 2.12.0 and shows the removal banner, or requirements.txt pins tensorflow-gpu
  2. 2TensorFlow 2.11 or newer running on native Windowsplatform.system() prints Windows, tf.__version__ is 2.11 or later, and the GPU list comes back as []
  3. 3tensorflow<2.11 pinned on a Python newer than 3.10pip finds no version for tensorflow<2.11, and python --version prints 3.11 or higher

What does the error look like?

  • The "tensorflow-gpu" package has been removed!
  • Please install "tensorflow" instead.
  • Other than the name, the two packages have been identical since TensorFlow 2.1, or roughly since Sep 2019.

Cause 1 of 3

The install command or requirements file still says tensorflow-gpu

You seepip fails while preparing tensorflow-gpu 2.12.0 and shows the removal banner, or requirements.txt pins tensorflow-gpu

Check

pip install tensorflow-gpu fails with the package has been removed message on purpose. The name was retired in December 2022, and its last upload, 2.12.0, is a source package whose setup.py raises an exception whenever pip tries to install it. Since TensorFlow 2.1 the plain tensorflow package has shipped the same CUDA support.

Check
grep -rn "tensorflow-gpu" requirements*.txt pyproject.toml setup.py Dockerfile

Fix

Swap tensorflow-gpu for tensorflow in every file and command. On Linux, the and-cuda extra also brings the NVIDIA CUDA and cuDNN libraries in as pip packages.

Fix
python3 -m pip uninstall -y tensorflow-gpu
python3 -m pip install 'tensorflow[and-cuda]'

Verify

The install completes, and TensorFlow returns a non-empty list of GPU devices.

Verify
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

Confirmed by pypi.org

Did this fix it?

Cause 2 of 3

TensorFlow 2.11 or newer running on native Windows

You seeplatform.system() prints Windows, tf.__version__ is 2.11 or later, and the GPU list comes back as []

Check

TensorFlow's install guide says 2.10 was the final release that used a GPU on native Windows; from 2.11 onward that build is CPU only. Nothing fails during install, so the model simply trains slowly on the processor.

Check
python -c "import tensorflow as tf; print(tf.__version__, tf.config.list_physical_devices('GPU'))"

Fix

Run the project inside WSL2, which needs Windows 10 build 19044 (21H2) or later. Set up NVIDIA GPU support for WSL2 as the guide links, confirm the GPU with nvidia-smi from the Linux shell, then install the CUDA-enabled package there.

Fix
# inside the WSL2 Linux shell
nvidia-smi
python3 -m pip install --upgrade pip
python3 -m pip install 'tensorflow[and-cuda]'

Verify

The same GPU check, run inside WSL2, returns a list of GPU devices.

Verify
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

Confirmed by tensorflow.org

Did this fix it?

Cause 3 of 3

tensorflow<2.11 pinned on a Python newer than 3.10

You seepip finds no version for tensorflow<2.11, and python --version prints 3.11 or higher

Check

Keeping a GPU on native Windows means staying on TensorFlow 2.10. Its tested Windows GPU build lists Python 3.7 to 3.10, cuDNN 8.1 and CUDA 11.2, so a newer interpreter has no matching wheel. The current 2.21 release covers Python 3.10 to 3.13 instead, without the Windows GPU.

Check
python --version

Fix

Make a separate conda environment on an older Python, install the CUDA 11.2 and cuDNN 8.1 libraries from conda-forge as the guide shows, and pin TensorFlow below 2.11 with pip.

Fix
conda create --name tf python=3.9
conda activate tf
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
python -m pip install "tensorflow<2.11"

Verify

TensorFlow reports a 2.10 version and lists the GPU in the activated environment.

Verify
python -c "import tensorflow as tf; print(tf.__version__, tf.config.list_physical_devices('GPU'))"

Confirmed by tensorflow.org

Did this fix it?

How do I stop it coming back?

  • Search CI scripts, Dockerfiles and notebooks for tensorflow-gpu and replace it, because older tutorials still copy that name.
  • State in the README whether the project trains in WSL2 or on native Windows, and pin tensorflow to a version that has GPU support on that target.
  • Add a start-up check that stops a training job when tf.config.list_physical_devices('GPU') is empty on a machine meant to use a GPU.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: stegnor.com, Menulo, ShopGo.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.