mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-12 12:40:20 +08:00
Add warning for few workers (#1378)
* Add warning for few workers * Fix style issue * Update CHANGELOG.md * Update test * formatting * formatting Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
This commit is contained in:
co-authored by
Jirka Borovec
parent
fdcf9cd518
commit
b18accc64c
@@ -15,6 +15,7 @@ from tests.base import (
|
||||
LightValStepFitMultipleDataloadersMixin,
|
||||
LightValStepFitSingleDataloaderMixin,
|
||||
LightTrainDataloader,
|
||||
LightValidationDataloader,
|
||||
LightInfTrainDataloader,
|
||||
LightInfValDataloader,
|
||||
LightInfTestDataloader,
|
||||
@@ -485,6 +486,47 @@ def test_error_on_zero_len_dataloader(tmpdir):
|
||||
trainer.fit(model)
|
||||
|
||||
|
||||
def test_warning_with_few_workers(tmpdir):
|
||||
""" Test that error is raised if dataloader with only a few workers is used """
|
||||
tutils.reset_seed()
|
||||
|
||||
class CurrentTestModel(
|
||||
LightTrainDataloader,
|
||||
LightValStepFitSingleDataloaderMixin,
|
||||
LightTestFitSingleTestDataloadersMixin,
|
||||
LightEmptyTestStep,
|
||||
TestModelBase,
|
||||
):
|
||||
pass
|
||||
|
||||
hparams = tutils.get_default_hparams()
|
||||
model = CurrentTestModel(hparams)
|
||||
|
||||
# logger file to get meta
|
||||
trainer_options = dict(
|
||||
default_save_path=tmpdir,
|
||||
max_epochs=1,
|
||||
val_percent_check=0.1,
|
||||
train_percent_check=0.2
|
||||
)
|
||||
|
||||
fit_options = dict(train_dataloader=model._dataloader(train=True),
|
||||
val_dataloaders=model._dataloader(train=False),
|
||||
test_dataloaders=model._dataloader(train=False))
|
||||
|
||||
trainer = Trainer(**trainer_options)
|
||||
|
||||
# fit model
|
||||
with pytest.warns(UserWarning, match='train'):
|
||||
trainer.fit(model, **fit_options)
|
||||
|
||||
with pytest.warns(UserWarning, match='val'):
|
||||
trainer.fit(model, **fit_options)
|
||||
|
||||
with pytest.warns(UserWarning, match='test'):
|
||||
trainer.test()
|
||||
|
||||
|
||||
@pytest.mark.skipif(torch.cuda.device_count() < 2, reason='Test requires multiple GPUs')
|
||||
def test_dataloader_reinit_for_subclass():
|
||||
|
||||
|
||||
Reference in New Issue
Block a user