mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-10 12:21:57 +08:00
When running DDP without DistributedSampler, throw warning instead of exception (#91)
This commit is contained in:
committed by
William Falcon
parent
c1434f0a3e
commit
996b1f9a6d
@@ -444,8 +444,9 @@ class Trainer(TrainerIO):
|
|||||||
|
|
||||||
if self.use_ddp and not isinstance(self.tng_dataloader.sampler, DistributedSampler):
|
if self.use_ddp and not isinstance(self.tng_dataloader.sampler, DistributedSampler):
|
||||||
msg = """
|
msg = """
|
||||||
when using multiple gpus and multiple nodes you must pass
|
You're using multiple gpus and multiple nodes without using a DistributedSampler
|
||||||
a DistributedSampler to DataLoader(sampler).
|
to assign a subset of your data to each process. To silence this warning, pass a
|
||||||
|
DistributedSampler to your DataLoader.
|
||||||
|
|
||||||
ie: this:
|
ie: this:
|
||||||
dataset = myDataset()
|
dataset = myDataset()
|
||||||
@@ -455,8 +456,10 @@ becomes:
|
|||||||
dataset = myDataset()
|
dataset = myDataset()
|
||||||
dist_sampler = torch.utils.data.distributed.DistributedSampler(dataset)
|
dist_sampler = torch.utils.data.distributed.DistributedSampler(dataset)
|
||||||
dataloader = Dataloader(dataset, sampler=dist_sampler)
|
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
|
# MODEL TRAINING
|
||||||
|
|||||||
@@ -665,7 +665,7 @@ def test_ddp_sampler_error():
|
|||||||
use_amp=True
|
use_amp=True
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(MisconfigurationException):
|
with pytest.warns(UserWarning):
|
||||||
trainer.get_dataloaders(model)
|
trainer.get_dataloaders(model)
|
||||||
|
|
||||||
clear_save_dir()
|
clear_save_dir()
|
||||||
|
|||||||
Reference in New Issue
Block a user