Skip to content

Conversation

@Mr-Neutr0n
Copy link

Summary

  • Uses os.environ.get('LOCAL_RANK', 0) instead of os.environ['LOCAL_RANK']
  • Prevents KeyError when running on single GPU without distributed training
  • Allows running with PyTorch >= 2.0 without explicitly setting LOCAL_RANK

Related Issue

Fixes #379

Test plan

  • Run training on single GPU without setting LOCAL_RANK
  • Verify distributed training still works correctly

Use os.environ.get() with default value 0 instead of direct dict
access to prevent KeyError when LOCAL_RANK is not set in the
environment. This allows running on a single GPU without needing
to set the environment variable.

Fixes microsoft#379
@Mr-Neutr0n
Copy link
Author

following up on this — fixes a KeyError crash when LOCAL_RANK isn't set as an environment variable (happens outside of torchrun). let me know if this looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KeyError: 'LOCAL_RANK'

1 participant