Skip to content

Commit

Permalink
Update data_loading.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthsub committed Oct 21, 2020
1 parent 9f7662b commit 984c73f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pytorch_lightning/trainer/data_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,11 @@ def auto_add_sampler(self, dataloader: DataLoader, train: bool) -> DataLoader:

if not is_dataloader or is_iterable_ds:
return dataloader
need_dist_sampler = (self.use_ddp or self.use_ddp2 or self.use_horovod or self.use_tpu)

is_in_dist = self.use_ddp or self.use_ddp2 or self.use_horovod or self.use_tpu
need_dist_sampler = is_in_dist and not isinstance(dataloader.sampler, DistributedSampler)
if self.replace_sampler_ddp and need_dist_sampler:
if isinstance(dataloader.sampler, DistributedSampler):
return dataloader
elif not isinstance(dataloader.sampler, (SequentialSampler, RandomSampler)):
if not isinstance(dataloader.sampler, (SequentialSampler, RandomSampler)):
raise MisconfigurationException(
'You seem to have configured a sampler in your DataLoader. This will be replaced '
' by `DistributedSampler` since `replace_sampler_ddp` is True and you are using'
Expand Down

0 comments on commit 984c73f

Please sign in to comment.