Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit 2f87832

Browse files
authored
only show validation progress bar from main process (#4476)
* only show validation progress bar from main process * fix
1 parent 9144918 commit 2f87832

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Fixed a bug that erronously increased last label's false positive count in calculating fbeta metrics.
3535
- `Tqdm` output now looks much better when the output is being piped or redirected.
3636
- Small improvements to how the API documentation is rendered.
37+
- Only show validation progress bar from main process in distributed training.
3738

3839
### Added
3940

allennlp/training/trainer.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,14 @@ def _validation_loss(self, epoch: int) -> Tuple[float, float, int]:
707707
)
708708

709709
regularization_penalty = self.model.get_regularization_penalty()
710-
val_generator_tqdm = Tqdm.tqdm(validation_data_loader)
710+
711+
# Having multiple tqdm bars in case of distributed training will be a mess. Hence only the master's
712+
# progress is shown
713+
if self._master:
714+
val_generator_tqdm = Tqdm.tqdm(validation_data_loader)
715+
else:
716+
val_generator_tqdm = validation_data_loader
717+
711718
batches_this_epoch = 0
712719
val_loss = 0
713720
if regularization_penalty is not None:
@@ -760,7 +767,8 @@ def _validation_loss(self, epoch: int) -> Tuple[float, float, int]:
760767
)
761768

762769
description = training_util.description_from_metrics(val_metrics)
763-
val_generator_tqdm.set_description(description, refresh=False)
770+
if self._master:
771+
val_generator_tqdm.set_description(description, refresh=False)
764772

765773
for callback in self._batch_callbacks:
766774
callback(

0 commit comments

Comments
 (0)