How to Check TensorFlow GPU Detection and Diagnose Common Failures

How to verify TensorFlow GPU detection with tf.config.list_physical_devices, diagnose CUDA version mismatches, driver issues, and common failure modes.

How to Check TensorFlow GPU Detection and Diagnose Common Failures
Written by TechnoLynx Published on 06 May 2026

We find that tensorFlow failing to find a GPU is one of the most common setup problems in ML engineering. The symptom is consistent — training runs but only on CPU, silently — and the causes are specific and diagnosable. This article covers the verification commands, the common failure modes, and the systematic diagnostic approach to get from “TensorFlow can’t find my GPU” to a working configuration.

Verifying GPU Detection

The definitive check is tf.config.list_physical_devices:

import tensorflow as tf

gpus = tf.config.list_physical_devices('GPU')
print(f"GPUs available: {len(gpus)}")
for gpu in gpus:
    print(f"  {gpu}")

If this returns an empty list, TensorFlow cannot see any GPU. If it returns GPU devices, TensorFlow has successfully initialized the CUDA runtime and detected hardware.

A secondary check that also shows TensorFlow’s CUDA build configuration:

print(tf.test.is_built_with_cuda())      # True if TF was built with CUDA support
print(tf.test.is_gpu_available())         # Deprecated but still informative
print(tf.sysconfig.get_build_info())      # Shows CUDA and cuDNN versions TF was built against

For confirming actual GPU execution (not just detection):

import tensorflow as tf

with tf.device('/GPU:0'):
    a = tf.constant([[1.0, 2.0], [3.0, 4.0]])
    b = tf.constant([[5.0, 6.0], [7.0, 8.0]])
    c = tf.matmul(a, b)
    print(c)

If this executes without error and doesn’t fall back to CPU, GPU execution is confirmed.

What does this mean in practice?

This is the most frequent cause. TensorFlow has strict CUDA version requirements — a TF binary built against CUDA 11.8 will not work with CUDA 12.x installed, and vice versa.

Check what TensorFlow expects:

import tensorflow as tf
build_info = tf.sysconfig.get_build_info()
print(f"CUDA version TF built with: {build_info['cuda_version']}")
print(f"cuDNN version TF built with: {build_info['cudnn_version']}")

Check what’s installed:

nvcc --version                    # CUDA toolkit version
nvidia-smi                        # Driver version and CUDA compatibility
cat /usr/local/cuda/version.txt   # Installed CUDA version
ls /usr/local/cuda-*/             # All installed CUDA versions

TensorFlow CUDA compatibility matrix (key versions):

TensorFlow Version Python CUDA cuDNN
2.13 3.8–3.11 11.8 8.6
2.14 3.9–3.11 11.8 8.7
2.15 3.9–3.11 12.2 8.9
2.16 3.9–3.12 12.3 8.9
2.17 3.9–3.12 12.3 8.9

If there’s a mismatch, either install the TF version matching your CUDA, or install the CUDA version matching your TF. The simplest resolution is using tensorflow[and-cuda] with pip on Linux, which installs the correct CUDA libraries automatically for TF 2.12+:

pip install tensorflow[and-cuda]

2. Driver Version Too Old

The NVIDIA driver must be new enough to support the installed CUDA toolkit. CUDA 12.x requires driver ≥525.85 on Linux. Installing a new CUDA toolkit without updating the driver is a common mistake.

Check driver version:

nvidia-smi --query-gpu=driver_version --format=csv,noheader

Minimum driver versions:

CUDA Version Minimum Linux Driver Minimum Windows Driver
11.8 520.61 522.06
12.0 525.85 527.41
12.2 535.54 536.25
12.3 545.23 545.84
12.4 550.54 551.61

3. TensorFlow Not Built with GPU Support

The tensorflow package on PyPI for some platforms or CPU architectures is the CPU-only build. Verify:

pip show tensorflow | grep -i "version\|location"
python -c "import tensorflow as tf; print(tf.test.is_built_with_cuda())"

If is_built_with_cuda() returns False, you have the CPU-only package. On Linux, install tensorflow or tensorflow[and-cuda] from PyPI (GPU builds are default on Linux x86_64). On Apple Silicon Macs, use tensorflow -metal instead.

4. CUDA Libraries Not on Library Path

The CUDA runtime libraries (libcuda.so, libcudnn.so, libcublas.so) must be findable by the linker. If installed in non-standard locations:

ldconfig -p | grep libcuda      # Check if libcuda is in linker cache
ldconfig -p | grep libcudnn     # Check cuDNN
ls /usr/local/cuda/lib64/       # Check default CUDA lib location

Fix if libraries exist but aren’t found:

export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

For a permanent fix, add to /etc/ld.so.conf.d/ and run ldconfig.

5. GPU Not Visible in Container

In Docker/container environments, GPU visibility requires:

  • NVIDIA Container Toolkit installed on the host
  • --gpus all or --gpus "device=0" flag in the docker run command
  • Or deploy.resources.reservations.devices in docker-compose
docker run --gpus all nvidia/cuda:12.2-base nvidia-smi   # Verify container GPU access

Systematic Diagnostic Checklist

  • nvidia-smi runs and shows GPU? (If not: driver issue)
  • nvcc --version shows expected CUDA version? (If not: toolkit not installed or wrong PATH)
  • tf.test.is_built_with_cuda() returns True? (If not: wrong TF package)
  • tf.sysconfig.get_build_info()['cuda_version'] matches installed CUDA? (If not: version mismatch)
  • Driver version meets minimum for the CUDA version?
  • ldconfig -p | grep libcuda finds the library? (If not: library path issue)
  • In container: --gpus all flag present? NVIDIA Container Toolkit installed?
  • tf.config.list_physical_devices('GPU') returns devices? (Final confirmation)

Enabling GPU Memory Growth

After confirming GPU detection, enabling memory growth prevents TensorFlow from pre-allocating all available VRAM at startup (which blocks other processes):

gpus = tf.config.list_physical_devices('GPU')
for gpu in gpus:
    tf.config.experimental.set_memory_growth(gpu, True)

This is recommended for multi-process or multi-model environments.

The broader GPU configuration workflow for AI workloads — including NVIDIA system settings that affect TensorFlow performance — is covered in GPU Performance Settings for AI.

Where this leaves us

TensorFlow GPU detection failures have four common causes: CUDA version mismatch (most frequent), driver too old for the CUDA version, wrong TF package installed, and CUDA libraries not on the linker path. Each is diagnosable with specific commands. The systematic diagnostic checklist above resolves the issue in most cases without reinstalling the OS. For containerized deployments, the NVIDIA Container Toolkit and correct docker run flags are the additional requirements.

AMD vs NVIDIA for AI Inference: When the Cost-Per-Inference Calculus Shifts

AMD vs NVIDIA for AI Inference: When the Cost-Per-Inference Calculus Shifts

6/05/2026

When AMD beats NVIDIA on inference cost-per-dollar and when NVIDIA's TensorRT advantage reverses the equation.

CUDA Kernel Explained: Thread Hierarchy, Execution, and When to Write Your Own

CUDA Kernel Explained: Thread Hierarchy, Execution, and When to Write Your Own

6/05/2026

What a CUDA kernel is, how threads and blocks map to GPU hardware, and when custom kernels beat library calls.

GPU Stress Testing for AI: What Sustained Load Reveals That Benchmarks Hide

GPU Stress Testing for AI: What Sustained Load Reveals That Benchmarks Hide

6/05/2026

GPUs scoring identically on short benchmarks can differ by 15-30% under sustained load. How stress testing exposes the limits that benchmarks miss.

CUDA GPU Architecture and Programming: What Makes a GPU CUDA-Capable

CUDA GPU Architecture and Programming: What Makes a GPU CUDA-Capable

6/05/2026

What makes a GPU CUDA-capable, how CUDA compute capability tiers work, and what the architecture enables for parallel compute workloads.

GPU Benchmark Software for AI: What Each Tool Measures and What It Misses

GPU Benchmark Software for AI: What Each Tool Measures and What It Misses

6/05/2026

Consumer benchmarks measure the wrong thing for AI. AI benchmarks test the wrong workloads. What each GPU benchmark tool measures and what to use instead.

Benchmark Testing: What It Measures, What It Misses, and How to Do It Right for AI

Benchmark Testing: What It Measures, What It Misses, and How to Do It Right for AI

6/05/2026

Benchmark scores and real AI performance differ by 20-50%. How to test in a way that predicts actual workload behaviour rather than lab conditions.

AMD vs Intel for AI: Why Spec-Sheet Comparisons Mislead and What to Measure Instead

AMD vs Intel for AI: Why Spec-Sheet Comparisons Mislead and What to Measure Instead

6/05/2026

AMD vs Intel CPU performance for AI workloads varies by up to 3x depending on model architecture and software stack. No single 'better' answer exists.

AI Inference Infrastructure: Best Practices That Go Beyond Vendor Benchmark Claims

AI Inference Infrastructure: Best Practices That Go Beyond Vendor Benchmark Claims

5/05/2026

Inference infrastructure decisions should be driven by measured performance under your actual workload — vendor benchmarks rarely match production conditions.

Tensor Parallelism vs Pipeline Parallelism: Choosing the Right Strategy for Your GPU Cluster

Tensor Parallelism vs Pipeline Parallelism: Choosing the Right Strategy for Your GPU Cluster

5/05/2026

Tensor parallelism splits operations across GPUs (low latency, high bandwidth need). Pipeline parallelism splits layers (tolerates lower bandwidth, adds bubble overhead).

Choosing Efficient AI Inference Infrastructure: What to Measure Beyond Raw GPU Speed

Choosing Efficient AI Inference Infrastructure: What to Measure Beyond Raw GPU Speed

5/05/2026

Inference efficiency is performance-per-watt and cost-per-inference, not raw FLOPS. Batch size, precision, and memory bandwidth determine throughput.

CUDA Cores vs Tensor Cores: What Actually Determines AI Performance

CUDA Cores vs Tensor Cores: What Actually Determines AI Performance

5/05/2026

AI inference throughput depends primarily on tensor core utilisation, not CUDA core count. Tensor core generation determines supported precision formats.

CUDA Compute Capability Explained: What the Version Number Means for AI Workloads

CUDA Compute Capability Explained: What the Version Number Means for AI Workloads

5/05/2026

CUDA compute capability determines which tensor core operations and precision formats a GPU supports — not just whether CUDA runs.

How to Improve GPU Performance: A Profiling-First Approach to Compute Optimization

5/05/2026

Profiling must precede GPU optimisation. Memory bandwidth fixes typically deliver 2–5× more impact than compute-bound fixes for AI workloads.

BF16 vs FP16: When Dynamic Range Beats Precision and Vice Versa

5/05/2026

BF16 trades mantissa precision for dynamic range. The choice depends on whether your workload is gradient-dominated or activation-precision-dominated.

GPU Parallel Computing Explained: How Thousands of Cores Solve Problems Differently

5/05/2026

GPU parallelism exploits thousands of simple cores for data-parallel workloads. The execution model differs fundamentally from CPU thread-level parallelism.

AI TOPS Explained: Why This Popular Spec Tells You Almost Nothing About Real Performance

4/05/2026

TOPS measures theoretical throughput at one precision. It ignores memory bandwidth, software overhead, and workload fit — making it a poor performance predictor.

A100 GPU Rental Options: What Availability and Pricing Look Like in 2026

4/05/2026

A100 rental pricing varies 2–5× between providers depending on commitment length, region, and availability. Here is what the market looks like.

Agent Framework Selection for Edge-Constrained Inference Targets

2/05/2026

Selecting an agent framework for partial on-device inference: four axes that decide whether a desktop-class framework survives the edge-target boundary.

Distillation vs Quantisation for Multi-Platform Edge Inference: How to Choose

28/04/2026

Distillation and quantisation both shrink models for edge inference, but for three-or-more platforms only distillation keeps quality consistent.

GPU-Accelerating RF Signal Propagation Simulation: From Days to Hours

28/04/2026

Naive GPU porting of sequential RF simulation delivers modest gains. Algorithmic redesign to expose parallelism turns multi-day runtimes into hours.

What Cross-Platform GPU Performance Portability Requires

26/04/2026

Source-level portability is not performance portability. Competitive speed across GPU vendors needs architecture-aware abstraction and per-target tuning.

Cloud GPU vs On-Premise AI Accelerators: A Total Cost Analysis

25/04/2026

Cloud GPU suits variable, short-term workloads. On-premise is cheaper for sustained utilisation above 60%. The break-even is calculable, not philosophical.

How to Optimise AI Inference Latency on GPU Infrastructure

24/04/2026

Inference latency optimisation targets model compilation, batching, and memory management — not hardware speed. TensorRT and quantisation are key levers.

Algorithmic Restructuring vs Kernel Tuning: Choosing the Higher-Leverage GPU Optimisation

23/04/2026

Kernel tuning improves constant factors. Algorithmic restructuring changes complexity class. Identify your bottleneck type before committing effort.

How to Profile GPU Kernels to Find the Real Bottleneck

22/04/2026

GPU profiling separates compute-bound from memory-bound kernels. Nsight Compute roofline analysis shows where a kernel sits and what would move it.

The Hidden Cost of GPU Underutilisation

21/04/2026

Most GPU workloads use 30–50% of available compute. Without profiling, the waste is invisible. Bandwidth, occupancy, and serialisation are the root causes.

CUDA vs OpenCL vs SYCL: Choosing a GPU Compute API

20/04/2026

CUDA delivers the deepest optimisation on NVIDIA hardware. OpenCL and SYCL offer portability. Choose based on lock-in tolerance and performance needs.

GPU Performance Per Dollar — Why Cost, Efficiency, and Value Are Not the Same Metric

17/04/2026

Performance per dollar. Tokens per watt. Cost per request. These sound like the same thing said differently, but they measure genuinely different dimensions of AI infrastructure economics. Conflating them leads to infrastructure decisions that optimize for the wrong objective.

Precision Is an Economic Lever in Inference Systems

17/04/2026

Precision isn't just a numerical setting — it's an economic one. Choosing FP8 over BF16, or INT8 over FP16, changes throughput, latency, memory footprint, and power draw simultaneously. For inference at scale, these changes compound into significant cost differences.

Precision Choices Are Constrained by Hardware Architecture

17/04/2026

You can't run FP8 inference on hardware that doesn't have FP8 tensor cores. Precision format decisions are conditional on the accelerator's architecture — its tensor core generation, native format support, and the efficiency penalties for unsupported formats.

Steady-State Performance, Cost, and Capacity Planning

17/04/2026

Capacity planning built on peak performance numbers over-provisions or under-delivers. Real infrastructure sizing requires steady-state throughput — the predictable, sustained output the system actually delivers over hours and days, not the number it hit in the first five minutes.

Why Benchmarks Mislead AI Hardware Procurement — and How to Use Them Correctly

16/04/2026

A benchmark result starts with full context — workload, software stack, measurement conditions. By the time it reaches a procurement deck, all that context is gone. The failure mode is not wrong benchmarks but context loss during propagation.

Building an Audit Trail: Benchmarks as Evidence for Governance and Risk

16/04/2026

High-value AI hardware decisions need traceable evidence, not slide-deck bullet points. When benchmarks are documented with methodology, assumptions, and limitations, they become auditable institutional evidence — defensible under scrutiny and revisitable when conditions change.

The Comparability Protocol: Why Benchmark Methodology Defines What You Can Compare

16/04/2026

Two benchmark scores can only be compared if they share a declared methodology — the same workload, precision, measurement protocol, and reporting conditions. Without that contract, the comparison is arithmetic on numbers of unknown provenance.

How to Choose AI Hardware and GPU for AI Workloads: A Decision Framework

16/04/2026

Hardware selection is a multivariate decision under uncertainty — not a score comparison. This framework walks through the steps: defining the decision, matching evaluation to deployment, measuring what predicts production, preserving tradeoffs, and building a repeatable process.

How Benchmarks Shape Organizations Before Anyone Reads the Score

16/04/2026

Before a benchmark score informs a purchase, it has already shaped what gets optimized, what gets reported, and what the organization considers important. Benchmarks function as decision infrastructure — and that influence deserves more scrutiny than the number itself.

Accuracy Loss from Lower Precision Is Task‑Dependent

16/04/2026

Reduced precision does not produce a uniform accuracy penalty. Sensitivity depends on the task, the metric, and the evaluation setup — and accuracy impact cannot be assumed without measurement.

Precision Is a Design Parameter, Not a Quality Compromise

16/04/2026

Numerical precision is an explicit design parameter in AI systems, not a moral downgrade in quality. This article reframes precision as a representation choice with intentional trade-offs, not a concession made reluctantly.

Mixed Precision Works by Exploiting Numerical Tolerance

16/04/2026

Not every multiplication deserves 32 bits. Mixed precision works because neural network computations have uneven numerical sensitivity — some operations tolerate aggressive precision reduction, others don't — and the performance gains come from telling them apart.

Throughput vs Latency: Choosing the Wrong Optimization Target

16/04/2026

Throughput and latency are different objectives that often compete for the same resources. This article explains the trade-off, why batch size reshapes behavior, and why percentiles matter more than averages in latency-sensitive systems.

Quantization Is Controlled Approximation, Not Model Damage

16/04/2026

When someone says 'quantize the model,' the instinct is to hear 'degrade the model.' That framing is wrong. Quantization is controlled numerical approximation — a deliberate engineering trade-off with bounded, measurable error characteristics — not an act of destruction.

GPU Utilization Is Not Performance — Why Low GPU Utilization Often Means the Right Thing

15/04/2026

The utilization percentage in nvidia-smi reports kernel scheduling activity, not efficiency or throughput. This article explains the metric's exact definition, why it routinely misleads in both directions, and what to pair it with for accurate performance reads.

FP8, FP16, and BF16 Represent Different Operating Regimes

15/04/2026

FP8 is not just 'half of FP16.' Each numerical format encodes a different set of assumptions about range, precision, and risk tolerance. Choosing between them means choosing operating regimes — different trade-offs between throughput, numerical stability, and what the hardware can actually accelerate.

Peak Performance vs Steady‑State Performance in AI

15/04/2026

AI systems rarely operate at peak. This article defines the peak vs. steady-state distinction, explains when each regime applies, and shows why evaluations that capture only peak conditions mischaracterize real-world throughput.

The Software Stack Is a First‑Class Performance Component

15/04/2026

Drivers, runtimes, frameworks, and libraries define the execution path that determines GPU throughput. This article traces how each software layer introduces real performance ceilings and why version-level detail must be explicit in any credible comparison.

The Mythology of 100% GPU Utilization

15/04/2026

Is 100% GPU utilization bad? Will it damage the hardware? Should you be worried? For datacenter AI workloads, sustained high utilization is normal — and the anxiety around it usually reflects gaming-era intuitions that don't apply.

Why Benchmarks Fail to Match Real AI Workloads

15/04/2026

The word 'realistic' gets attached to benchmarks freely, but real AI workloads have properties that synthetic benchmarks structurally omit: variable request patterns, queuing dynamics, mixed operations, and workload shapes that change the hardware's operating regime.

Why Identical GPUs Often Perform Differently

15/04/2026

'Same GPU' does not imply the same performance. This article explains why system configuration, software versions, and execution context routinely outweigh nominal hardware identity.

Back See Blogs
arrow icon