Skip to content

Commit 98c6ac1

Browse files
committed
arch: Improve errors returned by incorrect combinations of deviceid and visible devices
1 parent a537422 commit 98c6ac1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

devito/arch/archinfo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ def get_visible_devices():
497497
)
498498
for v in device_vars:
499499
try:
500-
return tuple(int(i) for i in os.environ[v].split(','))
500+
return v, tuple(int(i) for i in os.environ[v].split(','))
501501
except ValueError:
502502
# Visible devices set via UUIDs or other non-integer identifiers.
503503
warning("Setting visible devices via UUIDs or other non-integer"
@@ -507,7 +507,7 @@ def get_visible_devices():
507507
# Environment variable not set
508508
continue
509509

510-
return None
510+
return None, None
511511

512512

513513
@memoized_func

devito/operator/operator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,15 +1398,15 @@ def _physical_deviceid(self):
13981398
rank = self.comm.Get_rank() if self.comm != MPI.COMM_NULL else 0
13991399
logical_deviceid = rank
14001400

1401-
visible_devices = get_visible_devices()
1401+
visible_device_var, visible_devices = get_visible_devices()
14021402
if visible_devices is None:
14031403
return logical_deviceid
14041404
else:
14051405
try:
14061406
return visible_devices[logical_deviceid]
14071407
except IndexError:
14081408
errmsg = (f"A deviceid value of {logical_deviceid} is not valid "
1409-
f"with VISIBLE_DEVICES={visible_devices}. Note that "
1409+
f"with {visible_device_var}={visible_devices}. Note that "
14101410
"deviceid corresponds to the logical index within the "
14111411
"visible devices, not the physical device index.")
14121412
raise ValueError(errmsg)

0 commit comments

Comments
 (0)