Skip to content

Commit f138df5

Browse files
committed
Loading train_dataloader before estimating max_batches
1 parent f0c243b commit f138df5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/lightning/pytorch/trainer/trainer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,9 @@ def predict_dataloaders(self) -> Optional[EVAL_DATALOADERS]:
15181518
@property
15191519
def num_training_batches(self) -> Union[int, float]:
15201520
"""The number of training batches that will be used during ``trainer.fit()``."""
1521+
if self.train_dataloader is None:
1522+
rank_zero_info("Loading `train_dataloader` to estimate number of training batches.")
1523+
self.fit_loop.setup_data()
15211524
return self.fit_loop.max_batches
15221525

15231526
@property

0 commit comments

Comments
 (0)