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

[Fix] Fix gpu occupying when running with cpu #795

Merged
merged 7 commits into from
Mar 4, 2024

Conversation

HydrogenSulfate
Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate commented Mar 4, 2024

PR types

Bug fixes

PR changes

Others

Describe

  1. 修复CPU运行时仍然会有1.2G GPU显存占用的问题。经排查问题出在两个部分
  • ppsci/arch/activation.py内全局变量act_func_dict初始化时,包含了含参激活层Swish,这会触发paddle内部的初始化,导致显存占用。将Swish改为lazy初始化后解决。
  • ppsci/utils/symbolic.py中的全局变量SYMPY_TO_PADDLE初始化时将paddle.zeros([])作为partial参数对paddle.heaviside进行了装饰,因此也会触发paddle内部的初始化,导致显存占用。将这一包装行为放至OperatorNode.__init__,让其变成lazy初始化后解决。

修改前(出现红框中的内容表示触发了paddle内部的初始化,显存被占用):
image

修改后:
image

Copy link

paddle-bot bot commented Mar 4, 2024

Thanks for your contribution!

Copy link
Collaborator

@zhiminzhang0830 zhiminzhang0830 left a comment

Choose a reason for hiding this comment

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

LGTM

@HydrogenSulfate HydrogenSulfate merged commit 2e8deb3 into PaddlePaddle:develop Mar 4, 2024
2 of 4 checks passed
@HydrogenSulfate HydrogenSulfate deleted the fix_init_cpu branch March 4, 2024 14:25
huohuohuohuohuo123 pushed a commit to huohuohuohuohuo123/PaddleScience that referenced this pull request Aug 12, 2024
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