File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1402,7 +1402,14 @@ def _physical_deviceid(self):
14021402 if visible_devices is None :
14031403 return logical_deviceid
14041404 else :
1405- return visible_devices [logical_deviceid ]
1405+ try :
1406+ return visible_devices [logical_deviceid ]
1407+ except IndexError :
1408+ errmsg = (f"A deviceid value of { logical_deviceid } is not valid "
1409+ f"with VISIBLE_DEVICES={ visible_devices } . Note that "
1410+ "deviceid corresponds to the logical index within the "
1411+ "visible devices, not the physical device index." )
1412+ raise ValueError (errmsg )
14061413 else :
14071414 return None
14081415
Original file line number Diff line number Diff line change @@ -149,6 +149,12 @@ def test_visible_devices_with_devito_deviceid(self):
149149 # So should be the second of the two visible devices specified (3)
150150 assert argmap ._physical_deviceid == 3
151151
152+ with switchenv ({'CUDA_VISIBLE_DEVICES' : "1" }), switchconfig (deviceid = 0 ):
153+ op1 = Operator (eq )
154+
155+ argmap1 = op1 .arguments ()
156+ assert argmap1 ._physical_deviceid == 1
157+
152158 @pytest .mark .parallel (mode = 2 )
153159 def test_deviceid_per_rank (self , mode ):
154160 """
You can’t perform that action at this time.
0 commit comments