Lightning-AI / pytorch-lightning

Pretrain, finetune and deploy AI models on multiple GPUs, TPUs with zero code changes.

Home Page:https://lightning.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hyperparameter logging with multiple loggers only works partially (TensorBoard and CSV)

simon-forb opened this issue · comments

Bug description

Inside my LightningModule, I use self.logger.log_hyperparams(...) to log, e.g.:

self.logger.log_hyperparams(dict(lr=lr, weight_decay=weight_decay))

In my trainer initialization, I define multiple loggers, e.g.:

trainer = Trainer(
        logger=[
            TensorBoardLogger(dir, name="tb_logs"),
            CSVLogger(dir, name="csv_logs"),
        ],
        ...
)

When fitting my model with this setup, the hyperparameters are only logged in the folder tb_logs which belongs to the TensorBoard logger (see code above). In the folder of the CSV logger, there is an empty hyperparameter file. I would have expected to have the same hyperparameter file as in the TensorBoard logger.

This occurs even after model fitting is complete, i.e., I can rule out that this occurs because the log is not yet flushed to disk.

What version are you seeing the problem on?

v2.2

How to reproduce the bug

No response

Error messages and logs

# Error messages and logs here please

Environment

Current environment
#- Lightning Component (e.g. Trainer, LightningModule, LightningApp, LightningWork, LightningFlow):
#- PyTorch Lightning Version (e.g., 1.5.0):
#- Lightning App Version (e.g., 0.5.2):
#- PyTorch Version (e.g., 2.0):
#- Python version (e.g., 3.9):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
#- Running environment of LightningApp (e.g. local, cloud):

More info

No response