Lightning-AI/pytorch-lightning

BatchSizeFinder throws KeyError: 'limit_eval_batches'

Open

#18,985 建立於 2023年11月10日

在 GitHub 查看
 (3 留言) (1 反應) (0 負責人)Python (3,233 fork)batch import
bugduplicatehelp wantedrepro neededtunerver: 2.1.x

倉庫指標

Star
 (26,687 star)
PR 合併指標
 (平均合併 9天 15小時) (30 天內合併 3 個 PR)

描述

Bug description

Using the latest Lightning-AI v 2.1

I have added vanilla BatchSizeFinder as a callback to my lightningmodule. After it finishes finding the correct batchsize, it breaks while calling function batch_size_scaling. The error message is:

File ~/miniconda3/envs/dl/lib/python3.10/site-packages/lightning/pytorch/tuner/batch_size_scaling.py:155, in __scale_batch_restore_params(trainer, params)
    153     stage = trainer.state.stage
    154     assert stage is not None
--> 155     setattr(trainer, f"limit_{stage.dataloader_prefix}_batches", params["limit_eval_batches"])
    157 loop.load_state_dict(deepcopy(params["loop_state_dict"]))
    158 loop.restarting = False

On debugging the params variable only has the following keys:

dict_keys(['loggers', 'callbacks', 'max_steps', 'limit_train_batches', 'limit_val_batches', 'loop_state_dict'])

So indeed the limit_eval_batches key does not exist in my lightningmodule. Happy to provide more info if needed.

Thanks

What version are you seeing the problem on?

v2.1

How to reproduce the bug

No response

Error messages and logs

# Error messages and logs here please

Environment

No response

More info

No response

貢獻者指南