Skip to content

Error while using custom DistributedSampler #7573

Discussion options

You must be logged in to vote

Adding on to the existing answer:

DataLoader(shuffle, sampler) are mutually exclusive, i.e., if you set shuffle=True you will get a RandomSampler and if it is set to False you get a SequentialSampler.

When using DDP, Lightning takes your dataloader and replaces it with the following
DataLoader(sampler=DistributedDampler(shuffle=True), ...), however ONLY if the sampler is not already a distributed sampler. If it is, no changes are done.

So OP can do the following:

def train_dataloader(self):
    return DataLoader(sampler=DistributedSampler(shuffle=False), ...)`

returning their own sampler. Note this needs to be done in a place where the distributed group is already initialized, so basicall…

Replies: 2 comments 5 replies

Comment options

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

@jmlemercier
Comment options

Comment options

You must be logged in to vote
3 replies
@jmlemercier
Comment options

@awaelchli
Comment options

@jmlemercier
Comment options

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