tqdm/tqdm

Update prints a new line each call

Closed this issue · 0 comments

  • I have marked all applicable categories:
    • exception-raising bug
    • visual output bug
  • I have visited the source website, and in particular
    read the known issues
  • I have searched through the issue tracker for duplicates
  • I have mentioned version numbers, operating system and
    environment, where applicable:
    import tqdm, sys
    print(tqdm.__version__, sys.version, sys.platform)
    >>>4.66.1 3.9.16 (main, Dec  8 2022, 00:00:00) 
    >>>[GCC 11.3.1 20221121 (Red Hat 11.3.1-4)] linux

I am currently using the huggingface Transformers library to train some LLMs. When I evaluating the model, tqdm prints a new line for each update as seen in the picture below.

Skjermbilde 2024-04-24 kl  17 39 49

There are two progress bars here, one for training (the first one) and one for evaluation (the one getting updated in the image). I'm just having this problem with the evaluation progress bar. It seems to me that this happens because the update function is called each time during the evaluation. The code for the evaluation bar is the following:

    def on_prediction_step(self, args, state, control, eval_dataloader=None, **kwargs):
        if state.is_world_process_zero and has_length(eval_dataloader):
            if self.prediction_bar is None:
                self.prediction_bar = tqdm(
                    total=len(eval_dataloader), dynamic_ncols=True
                )
            self.prediction_bar.update(1)

I am wondering if there is another way to update the progress bar so it doesn't create a new line on each update.