---
title: Progress bar
description: 'It prints to stdout and shows up to four different bars:'
canonical: 'https://lightning.ai/docs/pytorch/stable/reference/common/progress_bar'
---
# Progress bar {#progress-bar}

Lightning supports two different types of progress bars ([tqdm](https://github.com/tqdm/tqdm) and [rich](https://github.com/Textualize/rich)). `TQDMProgressBar` is used by default,
but you can override it by passing a custom `TQDMProgressBar` or `RichProgressBar` to the `callbacks` argument of the `Trainer`.

You could also use the `ProgressBar` class to implement your own progress bar.

## TQDMProgressBar {#tqdmprogressbar}

The `TQDMProgressBar` uses the [tqdm](https://github.com/tqdm/tqdm) library internally and is the default progress bar used by Lightning.
It prints to `stdout` and shows up to four different bars:

- **sanity check progress:** the progress during the sanity check run
- **train progress:** shows the training progress. It will pause if validation starts and will resume when it ends, and also accounts for multiple validation runs during training when `lightning.pytorch.trainer.trainer.Trainer.val_check_interval` is used.
- **validation progress:** only visible during validation; shows total progress over all validation datasets.
- **test progress:** only active when testing; shows total progress over all test datasets.

For infinite datasets, the progress bar never ends.

You can update `refresh_rate` (rate (number of batches) at which the progress bar get updated) for `TQDMProgressBar` by:

```python
from lightning.pytorch.callbacks import TQDMProgressBar

trainer = Trainer(callbacks=[TQDMProgressBar(refresh_rate=10)])
```

> **Note**
>
> The `smoothing` option has no effect when using the default implementation of `TQDMProgressBar`, as the progress bar is updated using the `bar.refresh()` method instead of `bar.update()`. This can cause the progress bar to become desynchronized with the actual progress. To avoid this issue, you can use the `bar.update()` method instead, but this may require customizing the `TQDMProgressBar` class.

By default the training progress bar is reset (overwritten) at each new epoch.
If you wish for a new progress bar to be displayed at the end of every epoch, set
`TQDMProgressBar.leave <lightning.pytorch.callbacks.TQDMProgressBar.leave>` to `True`.

```python
trainer = Trainer(callbacks=[TQDMProgressBar(leave=True)])
```

If you want to customize the default `TQDMProgressBar` used by Lightning, you can override
specific methods of the callback class and pass your custom implementation to the `Trainer`.

```python
class LitProgressBar(TQDMProgressBar):
    def init_validation_tqdm(self):
        bar = super().init_validation_tqdm()
        bar.set_description("running validation...")
        return bar

trainer = Trainer(callbacks=[LitProgressBar()])
```

> **See also**
>
> - `TQDMProgressBar` docs.
> - [tqdm library](https://github.com/tqdm/tqdm)

## RichProgressBar {#richprogressbar}

[Rich](https://github.com/Textualize/rich) is a Python library for rich text and beautiful formatting in the terminal.
To use the `RichProgressBar` as your progress bar, first install the package:

```bash
pip install rich
```

Then configure the callback and pass it to the `Trainer`:

```python
from lightning.pytorch.callbacks import RichProgressBar

trainer = Trainer(callbacks=[RichProgressBar()])
```

Customize the theme for your `RichProgressBar` like this:

```python
from lightning.pytorch.callbacks import RichProgressBar
from lightning.pytorch.callbacks.progress.rich_progress import RichProgressBarTheme

# create your own theme!
progress_bar = RichProgressBar(
    theme=RichProgressBarTheme(
        description="green_yellow",
        progress_bar="green1",
        progress_bar_finished="green1",
        progress_bar_pulse="#6206E0",
        batch_progress="green_yellow",
        time="grey82",
        processing_speed="grey82",
        metrics="grey82",
        metrics_text_delimiter="\n",
        metrics_format=".3e",
    )
)

trainer = Trainer(callbacks=progress_bar)
```

You can customize the components used within `RichProgressBar` with ease by overriding the
`configure_columns` method.

```python
from rich.progress import TextColumn

custom_column = TextColumn("[progress.description]Custom Rich Progress Bar!")

class CustomRichProgressBar(RichProgressBar):
    def configure_columns(self, trainer):
        return [custom_column]

progress_bar = CustomRichProgressBar()
```

If you wish for a new progress bar to be displayed at the end of every epoch, you should enable
`RichProgressBar.leave <lightning.pytorch.callbacks.RichProgressBar.leave>` by passing `True`

```python
from lightning.pytorch.callbacks import RichProgressBar

trainer = Trainer(callbacks=[RichProgressBar(leave=True)])
```

> **See also**
>
> - `RichProgressBar` docs.
> - `RichModelSummary` docs to customize the model summary table.
> - [Rich library](https://github.com/Textualize/rich).

> **Note**
>
> Progress bar is automatically enabled with the Trainer, and to disable it, one should do this:
>
> ```python
> trainer = Trainer(enable_progress_bar=False)
> ```

---

**Navigation**

- Parent: [Common](/docs/pytorch/2.6.6/reference/common.md)
