Skip to content

Commit 242fb06

Browse files
committed
fix: rich progress bar error when resume training
1 parent b36edc4 commit 242fb06

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,13 @@ def refresh(self) -> None:
357357
def on_train_start(self, trainer: "pl.Trainer", pl_module: "pl.LightningModule") -> None:
358358
self._init_progress(trainer)
359359

360+
# Initialize the training progress bar here because
361+
# `on_train_epoch_start` is not called when resuming from a mid-epoch restart
362+
total_batches = self.total_train_batches
363+
train_description = self._get_train_description(trainer.current_epoch)
364+
assert self.progress is not None
365+
self.train_progress_bar_id = self._add_task(total_batches, train_description)
366+
360367
@override
361368
def on_predict_start(self, trainer: "pl.Trainer", pl_module: "pl.LightningModule") -> None:
362369
self._init_progress(trainer)

0 commit comments

Comments
 (0)