Skip to content

Commit

Permalink
Internal Change. DO NOT SUBMIT: Remove this line after the baseline is
Browse files Browse the repository at this point in the history
submitted.

PiperOrigin-RevId: 718995567
  • Loading branch information
yangustc07 authored and Google-ML-Automation committed Jan 23, 2025
1 parent 1d01696 commit 47ae228
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion jax/_src/xla_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,9 @@ def _init_backend(platform: str) -> xla_client.Client:
# factories instead of returning None.
if backend is None:
raise RuntimeError(f"Could not initialize backend '{platform}'")
if backend.device_count() == 0:
# TODO(b/356678989): Only check `backend.device_count()` when it counts
# CPU-only devices.
if backend.device_count() == 0 and len(backend._get_all_devices()) == 0:
raise RuntimeError(f"Backend '{platform}' provides no devices.")
util.distributed_debug_log(("Initialized backend", backend.platform),
("process_index", backend.process_index()),
Expand Down
6 changes: 6 additions & 0 deletions tests/xla_bridge_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,15 @@ def device_count(self):
def process_index(self):
return 0

def devices(self):
return []

def local_devices(self):
return []

def _get_all_devices(self):
return self.devices()

def _register_factory(self, platform: str, priority, device_count=1,
assert_used_at_most_once=False, experimental=False):
if assert_used_at_most_once:
Expand Down

0 comments on commit 47ae228

Please sign in to comment.