-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Delete state_dict
to release memory as early as possible
#18832
Conversation
The documentation is not available anymore as the PR was closed or merged. |
The change regarding having a new argument src/transformers/modeling_utils.py:422:17: F821 undefined name 'state_dict' with the new line |
b4e52bd
to
45db5e6
Compare
Ready for review. |
The failing test is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks @ydshieh!
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
…ce#18832) Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
What does this PR do?
Fix #18782.
Note that this is not a real memory issue. A call to
gc.collect()
at the end offrom_pretrained()
works well too.However this PR finds and simply
del state_dict
at the end of_load_state_dict_into_model()
, andGC
is able to perform housekeeping on its own at a earlier time.