Skip to content

Commit ad47219

Browse files
committed
fix
1 parent 2ddbfc7 commit ad47219

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

swift/cli/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
def try_use_single_device_mode():
55
if os.environ.get('SWIFT_SINGLE_DEVICE_MODE', '0') == '1':
66
visible_devices = os.environ['CUDA_VISIBLE_DEVICES'].split(',')
7-
visible_device = visible_devices[int(os.environ['LOCAL_RANK'])]
7+
local_rank = os.environ.get('LOCAL_RANK')
8+
if local_rank is None or not visible_devices:
9+
return
10+
visible_device = visible_devices[int(local_rank)]
811
os.environ['CUDA_VISIBLE_DEVICES'] = str(visible_device)
912
os.environ['LOCAL_RANK'] = '0'

0 commit comments

Comments
 (0)