Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

AI and LLM integration · Decision guide

JAX stops with FAILED_PRECONDITION before the first GPU operation

Short answer

XlaRuntimeError FAILED_PRECONDITION: DNN library initialization failed means XLA could not start cuDNN. The log lines printed just before it name the reason: an older cuDNN loaded ahead of the one jaxlib needs, GPU memory already claimed by TensorFlow or another process, or a driver too old for the CUDA wheel. Applies to JAX 0.12 with jax[cuda12] or jax[cuda13].

  • Applies to JAX and jaxlib 0.12.1, jax[cuda13] and jax[cuda12] pip wheels on Linux, NVIDIA driver 580+ for CUDA 13, 525+ for CUDA 12
  • Updated
  • By Maaz Zindani, Senior Software Engineer

DNN library initialization failed is the last line of the story, not the first. XLA tried to start cuDNN, NVIDIA's deep-learning library, and could not. The exception itself says to look at the errors above it, and those lines name the real reason. Three reasons cover most cases: an older cuDNN was loaded ahead of the one jaxlib needs, GPU memory was already taken, or the NVIDIA driver is too old for the CUDA wheel.

Run one tiny GPU operation and keep only the lines that matter. Which line you get decides the branch.

Find your case

  1. If the log says Loaded runtime CuDNN library: X but source was compiled with: Y, and X is lowerAn older cuDNN is being loaded first.
  2. If it says Could not create cudnn handle, followed by a Memory usage line with little freeGPU memory was claimed before cuDNN started.
  3. If it says CUDNN_STATUS_NOT_INITIALIZED and Possibly insufficient driver versionThe NVIDIA driver is older than the wheel needs.

Capture the lines that name the reason

One computation, filtered log, installed packages

python -c "import jax, jax.numpy as jnp; print(jax.devices(), jnp.ones((2, 2)) @ jnp.ones((2, 2)))" 2>&1 | grep -E "Loaded runtime CuDNN|cudnn handle|Memory usage|driver version|FAILED_PRECONDITION"
python -m pip list 2>/dev/null | grep -iE "^jax|cudnn|tensorflow|torch"

An older cuDNN wins

The failure follows that line when the cuDNN found at run time has a lower minor version than the one XLA was compiled against. JAX's CUDA 12 wheel wants cuDNN 9.10.2 or newer below 10. An old system or conda cuDNN on LD_LIBRARY_PATH, or one that TensorFlow loaded into the same process first, takes priority over the pip copy.

Clear LD_LIBRARY_PATH for this shell and reinstall JAX with its pip-provided CUDA libraries, which JAX's installation guide recommends over a local CUDA install. If another framework shares the process, make sure the cuDNN it loads is at least the version JAX reports, or run the two in separate processes.

Remove the competing library path, reinstall

echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
unset LD_LIBRARY_PATH
python -m pip install --upgrade "jax[cuda13]"
# or, for the CUDA 12 build:
# python -m pip install --upgrade "jax[cuda12]"

GPU memory is already taken

When cuDNN cannot get a handle, XLA logs the free and total GPU memory on the next line. JAX preallocates 75% of GPU memory on its first operation, and TensorFlow preallocates too, so two JAX processes, or JAX and GPU TensorFlow together, can leave cuDNN without room. nvidia-smi shows who holds the memory.

Stop grabbing memory up front

export XLA_PYTHON_CLIENT_PREALLOCATE=false
# or give each process a fixed share:
export XLA_CLIENT_MEM_FRACTION=.40
# in Python, before TensorFlow touches the GPU:
# tf.config.experimental.set_visible_devices([], "GPU")

The driver is too old

XLA prints the driver line only when cuDNN reports NOT_INITIALIZED. JAX's install guide asks for driver 525 or newer with the CUDA 12 wheels on Linux and 580 or newer with the CUDA 13 wheels, which also need a GPU of compute capability 7.5 or higher.

Update the driver. If you cannot, on a shared cluster for example, move to the CUDA 12 wheels, which accept an older driver, or try NVIDIA's CUDA forward compatibility packages as the guide suggests.

Check the driver, fall back to the CUDA 12 wheels

nvidia-smi | head -n 4
python -m pip uninstall -y jax-cuda13-plugin jax-cuda13-pjrt
python -m pip install --upgrade "jax[cuda12]"

If no cuDNN line appears at all

Try a fresh virtual environment with only jax[cuda13] installed. JAX maintainers read this error as a sign of a broken install, and suggest looking for other CUDA copies on the machine. Keep LD_LIBRARY_PATH out of the environments where JAX runs on pip-installed CUDA, including Dockerfiles and cluster module files, and write the wheel-to-driver pairing into the project README.

In short

  • The exception is generic; the log lines above it name the cause.
  • Three causes: older cuDNN loaded first, memory already claimed, or an old driver.
  • Prefer the pip-provided CUDA libraries and keep LD_LIBRARY_PATH empty.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Next step

Want a second pair of eyes on it?

Send me the error and what changed before it started. I reply within 24 hours.