Skip to content

Commit

Permalink
Make TPU detection more robust (#5271)
Browse files Browse the repository at this point in the history
  • Loading branch information
will-cromar authored and JackCaoG committed Jul 10, 2023
1 parent bfb85fa commit cba267f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torch_xla/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _maybe_select_default_device():
logging.warning('For more information about the status of PJRT, see '
'https://github.com/pytorch/xla/blob/master/docs/xr.md')
# Check for libtpu _and_ the TPU device
if torch_xla._found_libtpu and os.path.exists('/dev/accel0'):
if torch_xla._found_libtpu and tpu.num_available_chips() > 0:
logging.warning('libtpu.so and TPU device found. Setting PJRT_DEVICE=TPU.')
os.environ[xenv.PJRT_DEVICE] = 'TPU'
else:
Expand Down

0 comments on commit cba267f

Please sign in to comment.