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

[Dy2stat]fix no_grad context error in train mode when using save/load #36434

Merged
merged 2 commits into from
Oct 15, 2021

Conversation

0x45f
Copy link
Contributor

@0x45f 0x45f commented Oct 14, 2021

PR types

Bug fixes

PR changes

Others

Describe

修复使用jit.save/load接口加载模型后,在train模式和no_grad上下文中,显存会一直增长的问题。

使用了一个简单的线性层网络进行测试
image

修改之前使用jit.load加载模型,在train模式和no_grad上下文中,每次forward后显存都会增长。
image
在修改后显存占用会稳定在1126M
image

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@Aurelius84 Aurelius84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Aurelius84 Aurelius84 merged commit 37257d6 into PaddlePaddle:develop Oct 15, 2021
@0x45f 0x45f deleted the dy2stat_no_grad_for_save/load branch October 15, 2021 06:09
0x45f added a commit to 0x45f/Paddle that referenced this pull request Oct 15, 2021
…addle#36434)

* fix no_grad context error in train mode when using save/load

* change net to train mode in test case
@0x45f 0x45f changed the title fix no_grad context error in train mode when using save/load [Dy2stat]fix no_grad context error in train mode when using save/load Oct 18, 2021
lanxianghit pushed a commit that referenced this pull request Oct 18, 2021
…ing save/load (#36434) (#36463)

修复使用jit.save/load接口加载模型后,在train模式和no_grad上下文中,显存会一直增长的问题
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

Successfully merging this pull request may close these issues.

2 participants