[Fix] Fix gpu occupying when running with cpu #795
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
Bug fixes
PR changes
Others
Describe
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内部的初始化,显存被占用):
修改后: