PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
Apache License 2.0
39.75k stars 7.38k forks source link

FatalError: `Illegal instruction` is detected by the operating system. #12070

Closed outman closed 1 month ago

outman commented 1 month ago

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

@celery_app.task
def apply_ocr(sha256, img: bytes) -> dict:
    # Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换
    # 参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`。
    values = []
    ocr = PaddleOCR(use_angle_cls=True,
                    lang="ch",
                    det_model_dir=setting.det_model_dir,
                    rec_model_dir=setting.rec_model_dir,
                    cls_model_dir=setting.cls_model_dir)
    result = ocr.ocr(img, cls=True)
    for idx in range(len(result)):
        res = result[idx]
        for line in res:
            [_, text] = line
            [value, _] = text
            values.append(value)
    with SessionLocal() as session:
        record = OcrRecord(sha256=sha256,
                           content=json.dumps(values),
                           updated_at=ctime(),
                           created_at=ctime())
        session.add(record)
        session.commit()
    return {sha256: values}
celery-1  | [2024/05/07 13:57:03] ppocr DEBUG: Namespace(help='==SUPPRESS==', use_gpu=False, use_xpu=False, use_npu=False, ir_optim=True, use_tensorrt=False, min_subgraph_size=15, precision='fp32', gpu_mem=500, gpu_id=0, image_dir=None, page_num=0, det_algorithm='DB', det_model_dir='/workspace/storage/model/det', det_limit_side_len=960, det_limit_type='max', det_box_type='quad', det_db_thresh=0.3, det_db_box_thresh=0.6, det_db_unclip_ratio=1.5, max_batch_size=10, use_dilation=False, det_db_score_mode='fast', det_east_score_thresh=0.8, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_sast_score_thresh=0.5, det_sast_nms_thresh=0.2, det_pse_thresh=0, det_pse_box_thresh=0.85, det_pse_min_area=16, det_pse_scale=1, scales=[8, 16, 32], alpha=1.0, beta=1.0, fourier_degree=5, rec_algorithm='SVTR_LCNet', rec_model_dir='/workspace/storage/model/rec', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_batch_num=6, max_text_length=25, rec_char_dict_path='/usr/local/lib/python3.11/site-packages/paddleocr/ppocr/utils/ppocr_keys_v1.txt', use_space_char=True, vis_font_path='./doc/fonts/simfang.ttf', drop_score=0.5, e2e_algorithm='PGNet', e2e_model_dir=None, e2e_limit_side_len=768, e2e_limit_type='max', e2e_pgnet_score_thresh=0.5, e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_pgnet_valid_set='totaltext', e2e_pgnet_mode='fast', use_angle_cls=True, cls_model_dir='/workspace/storage/model/cls', cls_image_shape='3, 48, 192', label_list=['0', '180'], cls_batch_num=6, cls_thresh=0.9, enable_mkldnn=False, cpu_threads=10, use_pdserving=False, warmup=False, sr_model_dir=None, sr_image_shape='3, 32, 128', sr_batch_num=1, draw_img_save_dir='./inference_results', save_crop_res=False, crop_res_save_dir='./output', use_mp=False, total_process_num=1, process_id=0, benchmark=False, save_log_path='./log_output/', show_log=True, use_onnx=False, output='./output', table_max_len=488, table_algorithm='TableAttn', table_model_dir=None, merge_no_span_structure=True, table_char_dict_path=None, layout_model_dir=None, layout_dict_path=None, layout_score_threshold=0.5, layout_nms_threshold=0.5, kie_algorithm='LayoutXLM', ser_model_dir=None, re_model_dir=None, use_visual_backbone=True, ser_dict_path='../train_data/XFUND/class_list_xfun.txt', ocr_order_method=None, mode='structure', image_orientation=False, layout=True, table=True, ocr=True, recovery=False, use_pdf2docx_api=False, invert=False, binarize=False, alphacolor=(255, 255, 255), lang='ch', det=True, rec=True, type='ocr', ocr_version='PP-OCRv4', structure_version='PP-StructureV2')
celery-1  |
celery-1  |
celery-1  | --------------------------------------
celery-1  | C++ Traceback (most recent call last):
celery-1  | --------------------------------------
celery-1  | 0   paddle_infer::Predictor::Predictor(paddle::AnalysisConfig const&)
celery-1  | 1   std::unique_ptr<paddle::PaddlePredictor, std::default_delete<paddle::PaddlePredictor> > paddle::CreatePaddlePredictor<paddle::AnalysisConfig, (paddle::PaddleEngineKind)2>(paddle::AnalysisConfig const&)
celery-1  | 2   paddle::AnalysisPredictor::Init(std::shared_ptr<paddle::framework::Scope> const&, std::shared_ptr<paddle::framework::ProgramDesc> const&)
celery-1  | 3   paddle::AnalysisPredictor::PrepareProgram(std::shared_ptr<paddle::framework::ProgramDesc> const&)
celery-1  | 4   paddle::AnalysisPredictor::OptimizeInferenceProgram()
celery-1  | 5   paddle::inference::analysis::Analyzer::RunAnalysis(paddle::inference::analysis::Argument*)
celery-1  | 6   paddle::inference::analysis::IrAnalysisPass::RunImpl(paddle::inference::analysis::Argument*)
celery-1  | 7   paddle::inference::analysis::IRPassManager::Apply(std::unique_ptr<paddle::framework::ir::Graph, std::default_delete<paddle::framework::ir::Graph> >)
celery-1  | 8   paddle::framework::ir::Pass::Apply(paddle::framework::ir::Graph*) const
celery-1  | 9   paddle::framework::ir::SelfAttentionFusePass::ApplyImpl(paddle::framework::ir::Graph*) const
celery-1  | 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*)>)
celery-1  |
celery-1  | ----------------------
celery-1  | Error Message Summary:
celery-1  | ----------------------
celery-1  | FatalError: `Illegal instruction` is detected by the operating system.
celery-1  |   [TimeInfo: *** Aborted at 1715090223 (unix time) try "date -d @1715090223" if you are using GNU date ***]
celery-1  |   [SignalInfo: *** SIGILL (@0x7f5c7030fcda) received by PID 25 (TID 0x7f5c78460740) from PID 1882258650 ***]
celery-1  |
celery-1  | [2024-05-07 13:57:04,161: ERROR/MainProcess] Process 'ForkPoolWorker-4' pid:25 exited with 'signal 4 (SIGILL)'
celery-1  | [2024-05-07 13:57:04,180: ERROR/MainProcess] Task handler raised error: WorkerLostError('Worker exited prematurely: signal 4 (SIGILL) Job: 0.')
celery-1  | Traceback (most recent call last):
celery-1  |   File "/usr/local/lib/python3.11/site-packages/billiard/pool.py", line 1264, in mark_as_worker_lost
celery-1  |     raise WorkerLostError(
celery-1  | billiard.einfo.ExceptionWithTraceback:
celery-1  | """
celery-1  | Traceback (most recent call last):
celery-1  |   File "/usr/local/lib/python3.11/site-packages/billiard/pool.py", line 1264, in mark_as_worker_lost
celery-1  |     raise WorkerLostError(
celery-1  | billiard.exceptions.WorkerLostError: Worker exited prematurely: signal 4 (SIGILL) Job: 0.
celery-1  | """
UserWangZz commented 1 month ago

img: bytes 是否与输入图片是bytes类型有关呢?

outman commented 1 month ago

img: bytes 是否与输入图片是bytes类型有关呢?

我看了源码写入 bytes 是没问题的,不在 docker 的镜像里直接在操作系统为 aliyun os 3 的主机上也没问题。目前只是发现在基于 debian 的 python 镜像里出现了这个问题。不知道是不是有操作系统不兼容相关的问题。

UserWangZz commented 1 month ago

目前的报错信息是一个外部错误,Task handler raised error: WorkerLostError('Worker exited prematurely: signal 4 (SIGILL) Job: 0.')可以从这方面考虑一下

GreatV commented 1 month ago

看一下是不是和cpu指令集相关

GreatV commented 1 month ago

Duplicate of #11597

outman commented 1 month ago

Duplicate of https://github.com/PaddlePaddle/PaddleOCR/issues/11597