Tensorflow and CUDA version
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
TensorFlow GPU support depends on matching TensorFlow, CUDA, cuDNN, platform, and installation method. The important rule is not "pick any CUDA version near your TensorFlow version," but "use the compatibility combination documented for the TensorFlow release and install path you are actually using."
The Compatibility Question Has Changed
Older TensorFlow setups often required developers to install exact CUDA and cuDNN versions manually. Current TensorFlow guidance is more nuanced:
- for pip installs on supported Linux and WSL2 setups,
tensorflow[and-cuda]is now the official path - for source builds, TensorFlow still publishes CUDA and cuDNN compatibility tables
- native Windows GPU support ended after TensorFlow 2.10
So the right answer depends on whether you are installing wheels or building from source.
Current Official Source-Build Compatibility
According to TensorFlow's current official source-build compatibility table, these combinations apply for recent GPU builds:
- TensorFlow 2.20.0: CUDA 12.5 and cuDNN 9.3
- TensorFlow 2.19.0: CUDA 12.5 and cuDNN 9.3
- TensorFlow 2.18.0: CUDA 12.5 and cuDNN 9.3
- TensorFlow 2.17.0: CUDA 12.3 and cuDNN 8.9
- TensorFlow 2.16.1: CUDA 12.3 and cuDNN 8.9
- TensorFlow 2.15.0: CUDA 12.2 and cuDNN 8.9
These are source-build combinations, not a license to mix arbitrary package versions in an ad hoc environment.
Current Official Pip Guidance
For many Linux and WSL2 users, the official pip installation path is now:
This reduces manual CUDA dependency management compared with older instructions that required installing every NVIDIA library version yourself.
That said, platform still matters. TensorFlow's install page explicitly treats Linux, macOS, Windows native, and WSL2 differently.
Windows Native Is a Special Case
This is the rule many older answers miss: TensorFlow 2.10 was the last release with GPU support on native Windows. Starting with TensorFlow 2.11, official guidance is to use WSL2 for TensorFlow GPU workflows on Windows.
So if someone says "TensorFlow 2.15 plus CUDA on native Windows," the problem is not just CUDA matching. The platform itself is unsupported for official native-Windows GPU use.
Verify Instead of Guessing
After installation, verify what TensorFlow can actually see.
This does not replace the compatibility table, but it tells you whether the environment is actually loading GPU support.
When a Source Build Is Necessary
You may need a source build if:
- your GPU architecture is not well served by the published wheel
- you need a different CUDA or cuDNN setup than the official pip path expects
- you are working in an unusual enterprise environment with tightly controlled system libraries
TensorFlow's source-build guide also notes that starting from 2.18, GPU wheels can be built from source without a GPU present on the build machine.
Common Pitfalls
The biggest pitfall is following an old blog post that hardcodes a CUDA version without checking TensorFlow's current compatibility page. These combinations change over time.
Another issue is mixing installation models. A source-build compatibility table is not the same thing as the simplest pip installation recommendation for a standard Linux user.
Developers also waste time debugging CUDA version mismatches on native Windows with TensorFlow 2.11 and later, even though official native-Windows GPU support ended at 2.10.
Finally, do not stop at successful installation logs. Always verify GPU visibility from inside Python.
Summary
- Match TensorFlow, CUDA, and cuDNN according to TensorFlow's official compatibility guidance for your exact install method.
- For many Linux and WSL2 setups,
tensorflow[and-cuda]is now the official pip path. - Current source-build tables list recent combinations such as TensorFlow 2.20.0 with CUDA 12.5 and cuDNN 9.3.
- Native Windows GPU support officially stopped after TensorFlow 2.10.
- Verify the final environment with
tf.config.list_physical_devices("GPU")andtf.sysconfig.get_build_info().
Related reading
- Tensorflow apply op to each element of a 2d tensor
- TensorFlow argmax -min
- Tensorflow Attempting to use uninitialized value beta1_power
- Tensorflow Attempting to use uninitialized value beta1_power
- Tensorflow and Multiprocessing Passing Sessions
- tensorflow and tensorboard step vs relative
- Tensorflow Android demo load a custom graph in?
- Tensorflow._api.v2.train has no attribute 'AdamOptimizer
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.