PaddleOCR
PaddleOCR copied to clipboard
`Illegal instruction` when loading ppocrv4 chinese rec model on CPU
请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem
- 系统环境/System Environment:ubuntu 22.04
- 版本号/Version:Paddle:2.6 PaddleOCR:2.7.0.3 问题相关组件/Related components:PaddleOCR
- 运行指令/Command Code:NA
zh_ocr = PaddleOCR(
use_angle_cls=False,
det_model_dir="paddle/Multilingual_PP-OCRv3_det_infer",
rec_model_dir="paddle/ch_PP-OCRv4_rec_infer",
lang="ch"
)
- 完整报错/Complete Error Message:
--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
0 paddle_infer::Predictor::Predictor(paddle::AnalysisConfig const&)
1 std::unique_ptr<paddle::PaddlePredictor, std::default_delete<paddle::PaddlePredictor> > paddle::CreatePaddlePredictor<paddle::AnalysisConfig, (paddle::PaddleEngineKind)2>(paddle::AnalysisConfig const&)
2 paddle::AnalysisPredictor::Init(std::shared_ptr<paddle::framework::Scope> const&, std::shared_ptr<paddle::framework::ProgramDesc> const&)
3 paddle::AnalysisPredictor::PrepareProgram(std::shared_ptr<paddle::framework::ProgramDesc> const&)
4 paddle::AnalysisPredictor::OptimizeInferenceProgram()
5 paddle::inference::analysis::Analyzer::RunAnalysis(paddle::inference::analysis::Argument*)
6 paddle::inference::analysis::IrAnalysisPass::RunImpl(paddle::inference::analysis::Argument*)
7 paddle::inference::analysis::IRPassManager::Apply(std::unique_ptr<paddle::framework::ir::Graph, std::default_delete<paddle::framework::ir::Graph> >)
8 paddle::framework::ir::Pass::Apply(paddle::framework::ir::Graph*) const
9 paddle::framework::ir::SelfAttentionFusePass::ApplyImpl(paddle::framework::ir::Graph*) const
10 paddle::framework::ir::GraphPatternDetector::operator()(paddle::framework::ir::Graph*, std::function<void (std::map<paddle::framework::ir::PDNode*, paddle::framework::ir::Node*, paddle::framework::ir::GraphPatternDetector::PDNodeCompare, std::allocator<std::pair<paddle::framework::ir::PDNode* const, paddle::framework::ir::Node*> > > const&, paddle::framework::ir::Graph*)>)
----------------------
Error Message Summary:
----------------------
FatalError: `Illegal instruction` is detected by the operating system.
[TimeInfo: *** Aborted at 1708262756 (unix time) try "date -d @1708262756" if you are using GNU date ***]
[SignalInfo: *** SIGILL (@0x7fd4c821e70a) received by PID 1 (TID 0x7fd5b6068000) from PID 18446744072772249354 ***]
我们提供了AceIssueSolver来帮助你解答问题,你是否想要它来解答(请填写yes/no)?/We provide AceIssueSolver to solve issues, do you want it? (Please write yes/no):no
请尽量不要包含图片在问题中/Please try to not include the image in the issue. Only happens with this model
+10086 在CPU的环境下会出这种问题,GPU没有问题
I'm having the same issue
cc: @michaelowenliu
Same issue when using the --ocr option in command line "paddleocr"
问题解决了吗?
I'm having the same issue when use v4. v3 is ok
CPU 下使用 paddlepaddle==2.4.2,v4就可以了
Can anyone encountered this issue post your output of lscpu|grep -i flags
?
@GreatV and I can reproduce this issue on a CPU which has Instruction Set Extensions of at most avx2 (e.g.: intel i9). On a CPU that supports avx512 (e.g.: Xeon), this issue disappeared.
So we suspect this is related to support level of CPU's advanced instructions.
BTW, this is the script we experimented: https://aistudio.baidu.com/projectdetail/7844853
It is because of lack of AVX512, it has already been confirmed by https://github.com/PaddlePaddle/PaddleOCR/issues/10346, https://github.com/PaddlePaddle/PaddleOCR/issues/10675. I reproduce on both a Xeon and a AMD Ryzen 3, both don't support AVX512). So it is not a intel problem but a CPU instruction issue, and Paddle should not be expecting users to have CPUs supporting AVX512.
As far as I know, Paddle's support commitment to x86 advanced instructions is : sse is not supported, but, avx is supported. So, paddle is supposed to work on avx2 instructions. Considering this works on paddlepaddle 2.4.2, but failed on recent versions, this is a regression.
Let me ping intel engineers who might be interested in investigating this issue further. @bin1guo @xinyu-intel
Well as I said it is not a intel issue as i have it on AMD too. But if by "intel" you mean intel x86 then sure.
x86 is kind of agreement among AMD, intel and other vendors.
@zhanglirong1999 please check SelfAttentionFusePass if there are inlined avx512 assembly code in the implementation and try to disable this pass non non-avx512 platforms.
Considering this works on paddlepaddle 2.4.2
BTW this dont work on 2.4.2, it just defaults to some alternate, unusablely slow code path, which is https://github.com/PaddlePaddle/PaddleOCR/issues/10346 So something changed from 2.4.2 to 2.5.1 to not allow that code path anymore. But I won't say reverting to 2.4.2 is fixed because of the slow speed.
Thank you for reporting this issue. It can be fixed by PR , We skip SelfAttentionFusePass on non-avx512 platform
Thanks for the fix