Lightning-AI / pytorch-lightning

Pretrain, finetune ANY AI model of ANY size on multiple GPUs, TPUs with zero code changes.
https://lightning.ai
Apache License 2.0
28.17k stars 3.37k forks source link

Support batch size scaling with dataloaders passed directly to `fit()` #11604

Open akihironitta opened 2 years ago

akihironitta commented 2 years ago

🚀 Feature

This was first suggested/reported in #4000 and addressed in #4006 but then reverted in #4040 due to some GPU testing failure.

Currently, batch size scaling cannot be used with dataloaders passed directly to trainer.fit() as exception is raised at: https://github.com/PyTorchLightning/pytorch-lightning/blob/fe34bf2a653ebd50e6a3a00be829e3611f820c3c/pytorch_lightning/tuner/batch_size_scaling.py#L56-L58

The reason why this limitation was set is explained in #4006.

This limitation was set in place, to secure that the user had a field self.batch_size that we could alter. To remove this limitation we instead replaces the dataloader with a newly instantiated dataloader with altered batch size.

Motivation

Pitch

Alternatives

Additional context


If you enjoy Lightning, check out our other projects! âš¡

cc @borda @justusschock @awaelchli @ninginthecloud @rohitgr7 @otaj @akihironitta

rohitgr7 commented 2 years ago

looking forward to this, on how it can be done!

joonas-yoon commented 1 year ago

still open?

carmocca commented 1 year ago

Yes @joonas-yoon. Help wanted