How do I know if tensorflow using cuda and cudnn or not?
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
To know whether TensorFlow is actually using CUDA and cuDNN, you need more than “TensorFlow imported successfully.” The useful checks are: does TensorFlow see a GPU, was the build linked for CUDA, and do real GPU-friendly operations execute on that GPU. cuDNN is even more specific, because TensorFlow uses it only for certain supported operations such as convolutions and some recurrent layers.
Check Whether TensorFlow Sees a GPU
The first basic check is whether TensorFlow detects any GPU devices.
If the result is an empty list, TensorFlow is not using the GPU at all, which means CUDA and cuDNN are not active for your workload.
If a GPU appears, that is a strong first sign that CUDA support is working.
Inspect TensorFlow Build Info
TensorFlow can also report whether the installed build was compiled with CUDA support.
Useful fields often include whether CUDA and cuDNN support were compiled into the package and which versions the build expects.
This does not prove a specific model is currently using the GPU, but it tells you whether the TensorFlow package is even capable of it.
Run a Real Operation and Watch Device Placement
The next step is to execute GPU-relevant work and inspect placement.
If TensorFlow logs placement on /device:GPU:0, then TensorFlow is truly running the operation on the GPU rather than falling back to the CPU.
Use nvidia-smi While the Program Runs
A practical external check is NVIDIA’s process monitor.
While your TensorFlow script is actively running GPU work, nvidia-smi should show:
- the Python process or notebook kernel
- GPU memory allocation
- some level of utilization during computation
This is one of the fastest reality checks because it confirms activity outside the Python process itself.
What About cuDNN Specifically?
cuDNN is not a generic “GPU on” switch. TensorFlow uses cuDNN for certain supported deep-learning kernels, especially:
- convolution operations
- some RNN implementations
- related neural-network primitives
So to infer cuDNN usage, test an operation that normally maps to cuDNN, such as a convolution layer.
If the TensorFlow build is GPU-enabled and the environment is correct, these ops typically use GPU kernels backed by cuDNN where applicable.
Read the Startup Logs
TensorFlow often emits useful startup messages about GPU discovery, loaded libraries, and oneDNN or CUDA initialization. Those logs can reveal:
- GPU device registration
- missing CUDA libraries
- missing cuDNN libraries
- version mismatch problems
If TensorFlow cannot load the necessary runtime libraries, the logs usually say so early.
Common Failure Modes
You may have one of these situations:
- TensorFlow sees no GPU at all
- TensorFlow sees the GPU, but your workload still runs on CPU
- TensorFlow sees the GPU, but cuDNN-backed ops are unavailable because of version mismatch
- the Python package was installed without GPU support for that environment
That is why one check is not enough. Device detection, build info, and real operation placement together give a much more reliable answer.
Common Pitfalls
A common mistake is assuming that successful import means CUDA and cuDNN are active. Import success alone proves very little.
Another issue is checking only list_physical_devices('GPU') and stopping there. A visible GPU is good, but actual operation placement still matters.
Developers also sometimes expect every TensorFlow op to use cuDNN. cuDNN is used only for supported GPU kernels, not for every possible operation.
Finally, if nvidia-smi shows no active process during real work, TensorFlow is probably not using the GPU the way you think it is.
Summary
- First check whether TensorFlow detects any GPU devices.
- Inspect build info to confirm the package was built with CUDA support.
- Run real operations and enable device-placement logging to see where they execute.
- Use
nvidia-smiduring execution as an external sanity check. - cuDNN usage is best inferred from successful GPU execution of supported deep-learning ops such as convolutions.
Related reading
- How do I load a keras saved model with custom Optimizer
- How do I load a local model with torch.hub.load?
- How do I load custom image based datasets into Pytorch for use with a CNN?
- How do I make the initial state of an LSTM trainable in Keras?
- How do I make a ragged batch in Tensorflow 2.0?
- How do I pass a scalar via a TensorFlow feed dictionary
- How do I make a U-matrix?
- How do I plot a classification graph of a SVM in R
System design interview problems on this topic
- Design an LLM Inference Service: solution and walkthrough
- Design a GPU Cluster Scheduler for ML Training: solution and walkthrough
- Design ChatGPT: solution and walkthrough
- Design an E-commerce Recommendation System: solution and walkthrough
.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 courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.