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

使用Paddle NPU后端进行图片推理时,首次推理和每次更换图片都会导致速度变慢 #68107

Open
13244554253 opened this issue Sep 9, 2024 · 4 comments
Assignees

Comments

@13244554253
Copy link

13244554253 commented Sep 9, 2024

bug描述 Describe the Bug

描述:执行的是PaddleOCR中的官方demo tools/infer/predict_system.py 按照官方文档执行该脚本 仅修改use_npu参数为true,两张相同shape的图片1.jpg和2.jpg, 第一次推理1.jpg时速度会很慢,等第一次推理结束再推理1.jpg速度会很快,此时继续推理1.jpg速度依旧保持, 但切换为2.jpg速度会变慢,然后再次推理速度回归正常

模型:PP-OCRv4

环境:paddle==2.6.1 参照PaddleCustomDevice编译了昇腾910A后端

NPU: 昇腾910A
CANN:7.0.1
驱动版本:23.02

其他补充信息 Additional Supplementary Information

No response

@wangna11BD
Copy link
Contributor

第一次运行触发了jit编译,导致推理很慢,第二次换图像后由于图像变化导致算子运行的shape或者数值范围产生较大变化,还是有算子触发了jit编译,可以看看输出log里有没有Warning: tiling offset out of range, index: 32,这个log就是jit编译时的生成的。可以试试
1.把jit编译关了 export FLAGS_npu_jit_compile=0
2.多跑一些数据,一段时间后应该就不会再编译了,推理时间会稳定下来。

@13244554253
Copy link
Author

但是1.jpg编译后 后续再推理应该就没有这么慢了呀,但我把进行终止掉之后 再次启动推理1.jpg。第一次推理又会很慢,推理第二次速度才会正常

@wangna11BD
Copy link
Contributor

试试export FLAGS_npu_jit_compile=0呢,PaddlePaddle/PaddleX#1929 反馈有用

@13244554253
Copy link
Author

快是快了,但是提升不大。原来1分多钟,现在51s

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

No branches or pull requests

4 participants