Skip to content

Is it possible to access the global rank and world size outside of LightningModule? #8590

Discussion options

You must be logged in to vote

Issue ended up being torch.distributed.get_rank() and torch.distributed.get_world_size() aren't available when on a single GPU, which I was testing on locally before sending to multi-GPU server.

The following works:

if torch.distributed.is_available() and torch.distributed.is_initialized():
    file_paths = file_paths[
        torch.distributed.get_rank() :: torch.distributed.get_world_size()
    ]

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@EricWiener
Comment options

Comment options

You must be logged in to vote
2 replies
@tchaton
Comment options

@Yusifu
Comment options

Answer selected by EricWiener
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants