We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ddbfc7 commit ad47219Copy full SHA for ad47219
swift/cli/utils.py
@@ -4,6 +4,9 @@
4
def try_use_single_device_mode():
5
if os.environ.get('SWIFT_SINGLE_DEVICE_MODE', '0') == '1':
6
visible_devices = os.environ['CUDA_VISIBLE_DEVICES'].split(',')
7
- visible_device = visible_devices[int(os.environ['LOCAL_RANK'])]
+ 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)]
11
os.environ['CUDA_VISIBLE_DEVICES'] = str(visible_device)
12
os.environ['LOCAL_RANK'] = '0'
0 commit comments