TensorFlow
XLA
tf_xla_enable_xla_devices
Machine Learning
Deep Learning

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.

Practice ML system design

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.

python
1import tensorflow as tf
2
3@tf.function(jit_compile=True)
4def f(x, y):
5    return (x + y) * 2
6
7print(f(tf.constant(3.0), tf.constant(4.0)))

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.

bash
export TF_XLA_ENABLE_XLA_DEVICES=1
python train.py

Or in Windows PowerShell:

powershell
$env:TF_XLA_ENABLE_XLA_DEVICES = "1"
python train.py

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=1 only if your workflow specifically needs those devices.
  • Measure performance rather than assuming XLA is automatically beneficial.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track 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.

Practice ML system design