keras-team/keras · error · ValueError
Device not found
Error message
Device not found: {device_name} What it means
Raised by _to_backend_device after scanning jax.devices(backend=device_type): no live JAX device matches the requested type and index (e.g. 'gpu:1' with a single GPU, or any gpu on a CPU-only host). The device lookup itself failed, not the argument format.
Solutions
- Inspect available devices with jax.devices() and use a valid type:index pair.
- Use index 0 (e.g. 'gpu:0') when you have a single accelerator.
- On CPU-only environments use 'cpu:0' or jax.devices('cpu')[0].
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/backend/jax/distribution_lib.py:188 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/49401833eccf8a99.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/backend/jax/distribution_lib.py:188
def process_id():
"""Return the current process ID for the distribution setting."""
return jax.process_index()
def _to_backend_device(device_name):
if isinstance(device_name, jax.Device):
return device_name
device_name = str(device_name)
if ":" not in device_name:
device_type, device_id = device_name, 0
else:
device_type, device_id = device_name.split(":")
devices = jax.devices(backend=device_type)
for device in devices:
if device.platform == device_type and device.id == int(device_id):
return device
raise ValueError(f"Device not found: {device_name}")
def _to_backend_mesh(device_mesh):
"""Convert the DeviceMesh to JAX backend specific Mesh.
Args:
device_mesh: DeviceMesh instance to convert.
Returns:
A `jax.sharding.Mesh` instance.
"""
shape = device_mesh.devices.shape
devices = [_to_backend_device(d) for d in device_mesh.devices.flatten()]
devices = np.array(devices).reshape(shape)
return jax.sharding.Mesh(devices, device_mesh.axis_names)
def _to_backend_layout(tensor_layout):View on GitHub (pinned to 7a34a03db6)