Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix cpp_infer "--enable_mkldnn=false" not effective #13539

Merged
merged 2 commits into from
Jul 29, 2024

Conversation

hiroi-sora
Copy link
Contributor

@hiroi-sora hiroi-sora commented Jul 29, 2024

When using the --enable_mkldnn command line option, MKLDNN should be enabled when set to true and disabled when set to false. But, using the PaddlePaddle v3.0.0-beta1 inference library, the --enable_mkldnn=false option did not work as expected, causing MKLDNN to remain enabled regardless of the setting.

This commit adds a call to config.DisableMKLDNN() in the else branch to explicitly disable MKLDNN when --enable_mkldnn=false is set.


正常情况下,命令行指令 --enable_mkldnn=false 会关闭mkl加速。

使用旧版推理库(PaddlePaddle v2.3.2)时,如果不执行 config.EnableMKLDNN(); ,那么mkl默认是关闭的,指令没问题。

但是,使用新版推理库(PaddlePaddle v3.0.0-beta1)时,就算不执行 config.EnableMKLDNN(); ,mkl也是默认开启的。

这就导致 --enable_mkldnn=false 指令失效了。无论设置什么,mkl都是开启状态。

此PR增加了显式调用 config.DisableMKLDNN() 的代码,使得 --enable_mkldnn=false 时,可以正确地关闭mkl加速。

测试环境:

When using the --enable_mkldnn command line option, MKLDNN should be enabled when set to true and disabled when set to false. But, using the PaddlePaddle v3.0.0-beta1 inference library, the --enable_mkldnn=false option did not work as expected, causing MKLDNN to remain enabled regardless of the setting.

This commit adds a call to `config.DisableMKLDNN()` in the else branch to explicitly disable MKLDNN when `--enable_mkldnn=false` is set.
@CLAassistant
Copy link

CLAassistant commented Jul 29, 2024

CLA assistant check
All committers have signed the CLA.

@GreatV
Copy link
Collaborator

GreatV commented Jul 29, 2024

please install precommit to fix code style.

Copy link
Collaborator

@GreatV GreatV left a comment

Choose a reason for hiding this comment

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

LGTM

@GreatV GreatV merged commit 1923008 into PaddlePaddle:main Jul 29, 2024
3 checks passed
@luotao1
Copy link
Collaborator

luotao1 commented Oct 15, 2024

@hiroi-sora Thanks for your contribution! You will receive a beautiful PaddlePaddle gift. Please provide your mailing address by filling out the following questionnaire before October 18th.

Looking forward to the future, we will walk further together in the world of open source!
Click Here :https://paddle.wjx.cn/vm/h4On9gJ.aspx#

@luotao1
Copy link
Collaborator

luotao1 commented Nov 6, 2024

hi, @hiroi-sora

  • 非常感谢你对飞桨的贡献,我们正在运营一个PFCC组织,会通过定期分享技术知识与发布开发者主导任务的形式持续为飞桨做贡献,详情可见 https://github.com/luotao1 主页说明。
  • 如果你对PFCC有兴趣,请发送邮件至 ext_paddle_oss@baidu.com,我们会邀请你加入~

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants