Skip to content

Commit 087c752

Browse files
committed
changes to show correct progress bar numbers when using max_steps
1 parent fafc239 commit 087c752

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/lightning/pytorch/callbacks/progress/progress_bar.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ def total_train_batches(self) -> Union[int, float]:
8585
dataloader is of infinite size.
8686
8787
"""
88+
if (
89+
self.trainer.max_epochs == -1
90+
and self.trainer.max_steps is not None
91+
and self.trainer.max_steps > 0
92+
):
93+
remaining_steps = self.trainer.max_steps - self.trainer.global_step
94+
return min(self.trainer.num_training_batches, remaining_steps)
8895
return self.trainer.num_training_batches
8996

9097
@property

0 commit comments

Comments
 (0)