tensorflow Not creating XLA devices, tf_xla_enable_xla_devices not set
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
The message Not creating XLA devices, tf_xla_enable_xla_devices not set is usually informational, not a fatal error. It means TensorFlow did not create separate XLA virtual devices because the corresponding feature flag was not enabled, but that does not automatically mean your model is broken or that XLA-based optimization is impossible.
What XLA devices are
XLA is TensorFlow's compiler layer for optimizing graph execution. In some TensorFlow builds and workflows, TensorFlow can expose XLA devices explicitly, such as XLA_CPU or XLA_GPU style virtual devices.
The log message appears when TensorFlow decides not to create those explicit virtual devices because the feature flag is off.
That is different from saying "XLA can never be used."
Why the message appears
Older TensorFlow flows sometimes exposed XLA through environment flags such as TF_XLA_ENABLE_XLA_DEVICES=1. If the flag is absent, TensorFlow may log that it is not creating those devices.
In many cases, that is simply the default behavior.
So the message tells you about configuration, not necessarily about a failure in execution.
Do you need to fix it
Only if your workflow actually depends on explicit XLA devices.
Many TensorFlow 2 workflows use XLA through JIT compilation rather than by selecting an XLA_* device manually. For example, you can request compilation directly on a function.
This uses the modern API style and does not require you to manually place operations on a separate XLA device.
If you do want explicit XLA devices
For older or specific setups, you may enable the environment flag before starting Python.
Or in Windows PowerShell:
After that, some TensorFlow builds may expose the XLA devices explicitly.
Device placement versus compilation
One reason this message confuses people is that "XLA device" and "XLA compilation" sound like the same thing. They are related, but not identical in day-to-day TensorFlow usage.
Explicit XLA devices are one way a build may expose compiler-backed execution. JIT compilation through tf.function(jit_compile=True) is another route and is often the one modern TF2 users actually care about.
So if your model compiles and runs correctly with jit_compile=True, the absence of explicit XLA_* devices may not matter at all.
Benchmark before you care
Even when XLA is available, it does not guarantee speedups for every model. Some graphs benefit significantly from fusion and compilation, while others do not.
A sensible workflow is:
- verify correctness first
- enable XLA only for workloads that may benefit
- benchmark with and without it
- keep the simpler path if the gains are negligible
That is more useful than treating the log line itself as a performance signal.
Common Pitfalls
A common mistake is treating this message as a crash or configuration failure. It is often just an informational log line.
Another issue is forcing XLA on every workload without benchmarking. Compilation overhead can outweigh gains for small or dynamic workloads.
It is also easy to assume explicit XLA devices are required for all TensorFlow XLA usage. In TF2, JIT-compiled functions are often the more relevant interface.
Summary
- The message usually means explicit XLA virtual devices were not enabled.
- It is often informational rather than a real error.
- Modern TF2 code can often use XLA through
tf.function(jit_compile=True)instead. - Set
TF_XLA_ENABLE_XLA_DEVICES=1only if your workflow specifically needs those devices. - Measure performance rather than assuming XLA is automatically beneficial.
Related reading
- Tensorflow not detecting GPU - Adding visible gpu devices 0
- Tensorflow not running on GPU
- Tensorflow Object Detection API
- Tensorflow object detection mask rcnn uses too much memory
- Tensorflow not found on pip install inside Docker Container using Mac M1
- TensorFlow not found using pip
- tensorflow not tensorflow-gpu failed call to cuInit UNKNOWN ERROR 303
- TensorFlow NotFoundError Key not found in checkpoint
.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.