티스토리 뷰

Research (연구 관련)

Pytorch Lightning

홍돌 2024. 8. 2. 15:37

8/27/2024

Pytorch Lightning & Pytorch Compatibility

https://lightning.ai/docs/pytorch/stable/versioning.html#compatibility-matrix

자꾸 Pytorch 새로 깔려해서 빡치네. Pip에서 torch version에 맞게 알아서 Pytorch Lightning install 해야하는 거 아닌가? 반대가 아니라.


08/22/2024

Multi-gpu training setting in Pytorch Lightning version 2.4

Default strategy는 DDP인듯. 어찌어찌 하다보니 Pytorch Lightning update했는데 갑자기 SD가 requires_grad = False 인 것 때문에 생기는 문제로 인해 DDP를 그냥 쓰면 안되고 특별한 argument를 줘야했음.

https://lightning.ai/docs/pytorch/stable/common/trainer.html


08/02/2024

Background: ControlNet fine-tuning하려 그러는데 Pytorch Lightning으로 다 wrapping 되어있어서 튜토리얼 좀 보고 있음:

https://lightning.ai/docs/pytorch/stable/starter/introduction.html

다른건 모르겠는데 코드 모듈화해서 유지보수가 편할 것 같고 (솔직히 리서치코드를 누가 유지보수하겠냐만, 이런 코드 틀을 본인이 다른 프로젝트에 계속 가져가서 하면서 일종의 유지보수를 할 수도 있음), mixed precision 같은 최적화 기능을 편리하게 버그없이 넣을 수 있는 게 장점일 것 같음.

Is defining 'training_steps' method enough for the PL module?

Yes. Perhaps.

What about 'configure_optimizers' method? Is it necessary? 

Yes. https://lightning.ai/docs/pytorch/stable/common/lightning_module.html

 

LightningModule — PyTorch Lightning 2.3.3 documentation

LightningModule A LightningModule organizes your PyTorch code into 6 sections: When you convert to use Lightning, the code IS NOT abstracted - just organized. All the other code that’s not in the LightningModule has been automated for you by the Trainer.

lightning.ai

What is the default training epoch?

If both max_epochs and max_steps aren’t specified, max_epochs will default to 1000. To enable infinite training, set max_epochs = -1. https://lightning.ai/docs/pytorch/stable/common/trainer.html

What happens if you pass logger to the call_back argument of PL Trainer?

Just normal call_back... The methods like 'on_train_batch_end' can be overrided. https://lightning.ai/docs/pytorch/stable/extensions/callbacks.html

How does PL handle multi-gpu training?

Default is DDP. You can set any way. https://pytorch-lightning.readthedocs.io/en/0.9.0/multi_gpu.html

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함