Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pytorch_lightning/models/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,9 @@ def get_dataloaders(self, model):

if self.use_ddp and not isinstance(self.tng_dataloader.sampler, DistributedSampler):
msg = """
when using multiple gpus and multiple nodes you must pass
a DistributedSampler to DataLoader(sampler).
You're using multiple gpus and multiple nodes without using a DistributedSampler
to assign a subset of your data to each process. To silence this warning, pass a
DistributedSampler to your DataLoader.

ie: this:
dataset = myDataset()
Expand All @@ -455,8 +456,10 @@ def get_dataloaders(self, model):
dataset = myDataset()
dist_sampler = torch.utils.data.distributed.DistributedSampler(dataset)
dataloader = Dataloader(dataset, sampler=dist_sampler)

If you want each process to load the full dataset, ignore this warning.
"""
raise MisconfigurationException(msg)
warnings.warn(msg)

# -----------------------------
# MODEL TRAINING
Expand Down
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ def test_ddp_sampler_error():
use_amp=True
)

with pytest.raises(MisconfigurationException):
with pytest.warns(UserWarning):
trainer.get_dataloaders(model)

clear_save_dir()
Expand Down