Skip to content
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

Not auto add DistributedSampler for DDP training #1422

Closed
bobofzhang opened this issue Apr 9, 2020 · 0 comments · Fixed by #1425
Closed

Not auto add DistributedSampler for DDP training #1422

bobofzhang opened this issue Apr 9, 2020 · 0 comments · Fixed by #1425
Labels
bug Something isn't working help wanted Open to be worked on

Comments

@bobofzhang
Copy link

bobofzhang commented Apr 9, 2020

🐛 Bug

in 0.72, even if we don't set sampler, pytorch_lightning will not add DistributedSampler for us.

To Reproduce

the reason is in pytorch, if we don't set sampler, pytorch will add a sampler for us.
in pytorch's dataloader.py:

         if sampler is None:  # give default samplers
            if self._dataset_kind == _DatasetKind.Iterable:
                # See NOTE [ Custom Samplers and IterableDataset ]
                sampler = _InfiniteConstantSampler()
            else:  # map-style
                if shuffle:
                    sampler = RandomSampler(dataset)
                else:
                    sampler = SequentialSampler(dataset)

but in pytorch_lightning we check whether sampler is None to decide to add sampler
in data_loading.py funciton auto_add_sampler:

        no_sampler_added = dataloader.sampler is None

because pytorch have default sampler for us, which is not None, pytorch_lighting will not automatically add sampler.

@bobofzhang bobofzhang added bug Something isn't working help wanted Open to be worked on labels Apr 9, 2020
@Borda Borda changed the title Not auto add DistributedSampler for DDP training in 0.72 Not auto add DistributedSampler for DDP training Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Open to be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant