Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FixedFileNumModelCheckpoint callbackクラスの作成 #103

Open
1 task
Geson-anko opened this issue Sep 26, 2023 · 0 comments
Open
1 task

FixedFileNumModelCheckpoint callbackクラスの作成 #103

Geson-anko opened this issue Sep 26, 2023 · 0 comments
Assignees

Comments

@Geson-anko
Copy link
Member

Geson-anko commented Sep 26, 2023

概要

限られた数のCheckpointをファイルに保存する callbackクラスを作成します。
上限ファイル数までcheckpointを保持し、溢れたcheckpointファイルは古いものから削除します。

背景と目的

AMIは非常に長い時間活動するため、学習のたびにCheckpointを作成するとディスク容量を圧迫する恐れがあります。

古いパラメータファイルを削除していくことで、ディスク容量を小さく抑える狙いがあります。

ただ、喫緊の課題ではないので実装する優先順位は低いです。

提案内容

LightningのModelCheckpointクラスを継承し、改変して実装することを考えています。
https://lightning.ai/docs/pytorch/stable/api/lightning.pytorch.callbacks.ModelCheckpoint.html
https://lightning.ai/docs/pytorch/stable/_modules/lightning/pytorch/callbacks/model_checkpoint.html#ModelCheckpoint

  1. コンストラクタ__init__のキーワード引数に max_file_numを追加します。 そして、dequeを作成してそこにファイルパスを格納するようにします。

  2. _save_checkpointメソッドをラップして、保存するファイルパスをクラス内部に保存します。保存する際に最大数 max_file_numに達していた場合は、一番最後のファイルパスを取り出し、ファイルをディスクから削除したのちに、クラスからも削除します。

  3. super()._save_checkpointを呼び出し、checkpointを保存します。

スクリーンショット 2023-09-26 11 45 35

タスク

  • ...

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants