Is it possible to access the global rank and world size outside of LightningModule
?
#8590
-
Hi, I'm using an Is it possible to access the global rank or world size in a dataset (aka are there any utility functions available for this purpose)? I saw I tried using:
inside the IterableDataset, but it fails because the default process group has not been setup yet (which makes sense):
Is there any way to access the global rank/world size? If not, how would you recommend I check which GPU the dataset is on without causing an issue with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Where are you calling this? If this is inside a DataModule, you could implement this splitting inside your |
Beta Was this translation helpful? Give feedback.
-
Issue ended up being The following works:
|
Beta Was this translation helpful? Give feedback.
Issue ended up being
torch.distributed.get_rank()
andtorch.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: