-
Notifications
You must be signed in to change notification settings - Fork 473
fixing member reference #831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c97f04b
ac7e857
78cee30
a80650f
dfac846
2adbb0d
291c016
168dbfb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -311,7 +311,7 @@ def initialize_env(): | |
| rank = int(os.environ.get("RANK")) | ||
| world_size = int(os.environ.get("WORLD_SIZE")) | ||
| if "LOCAL_RANK" in os.environ: | ||
| local_rank = os.environ.get("LOCAL_RANK") | ||
| local_rank = int(os.environ.get("LOCAL_RANK")) | ||
| if local_rank is not None: | ||
| local_rank = int(local_rank) | ||
| else: | ||
|
|
@@ -548,30 +548,30 @@ def setup( | |
| manager._local_rank = local_rank | ||
|
|
||
| manager._device = torch.device( | ||
| f"cuda:{manager.local_rank}" if torch.cuda.is_available() else "cpu" | ||
| f"cuda:{manager._local_rank}" if torch.cuda.is_available() else "cpu" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any specific reason to switch to using private attributes here instead of the public property versions of these as was used before? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the external ones alias those internal ones, that is OK, but isn't it cleaner to use the internal ones for internal tasks? |
||
| ) | ||
|
|
||
| if manager._distributed: | ||
| # Setup distributed process group | ||
| try: | ||
| dist.init_process_group( | ||
| backend, | ||
| rank=manager.rank, | ||
| world_size=manager.world_size, | ||
| device_id=manager.device, | ||
| rank=manager._rank, | ||
| world_size=manager._world_size, | ||
| device_id=manager._device, | ||
| ) | ||
| except TypeError: | ||
| # device_id only introduced in PyTorch 2.3 | ||
| dist.init_process_group( | ||
| backend, | ||
| rank=manager.rank, | ||
| world_size=manager.world_size, | ||
| rank=manager._rank, | ||
| world_size=manager._world_size, | ||
| ) | ||
|
|
||
| if torch.cuda.is_available(): | ||
| # Set device for this process and empty cache to optimize memory usage | ||
| torch.cuda.set_device(manager.device) | ||
| torch.cuda.device(manager.device) | ||
| torch.cuda.set_device(manager._device) | ||
| torch.cuda.device(manager._device) | ||
| torch.cuda.empty_cache() | ||
|
|
||
| manager._initialization_method = method | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this int conversion handled in the next
ifblock? And won't this break whenLOCAL_RANKisNone?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can that happen? if LOCAL_RANK is set, can it still be None: like with
export LOCAL_RANK=
?