PaddleOCR icon indicating copy to clipboard operation
PaddleOCR copied to clipboard

PaddleOcr do not work on mac anymore

Open R4Ajeti opened this issue 11 months ago • 18 comments

Running this command on teminal just stuck your teminal and you cannot even stop it using "control + c" or "cmd + c" only "control + z" works to stop process:

$ paddleocr --image_dir ./imgs/rec-image.jpg --use_angle_cls true --use_gpu false

device: Apple M3 Pro - Macbook python version: 3.12.1 paddleocr==2.6.0.1 paddlepaddle==2.6.0 PyMuPDF==1.23.26

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

  • 系统环境/System Environment:
  • 版本号/Version:Paddle: PaddleOCR: 问题相关组件/Related components:
  • 运行指令/Command Code:
  • 完整报错/Complete Error Message:

请尽量不要包含图片在问题中/Please try to not include the image in the issue.

R4Ajeti avatar Mar 11 '24 01:03 R4Ajeti

we've noticed several reports, e.g. : #11079, but has not been able to reproduce this issue.

jzhang533 avatar Mar 11 '24 03:03 jzhang533

we've noticed several reports, e.g. : #11079, but has not been able to reproduce this issue.

I tried to downgrade those libraries pandas, numpy, PyMuPDF, opencv-contrib-python, opencv-python, paddlepaddle, paddlepaddle. But unlucky nothing worked for me.

R4Ajeti avatar Mar 11 '24 03:03 R4Ajeti

@jzhang533 Since you cannot reproduce the issue. Can you share pls the entire requirement.txt on what worked for you on mac using: "pip freeze > requirements.txt" so then I can play with it?

R4Ajeti avatar Mar 11 '24 03:03 R4Ajeti

  • my installed python packages: requirements.txt
  • OS: macOS 12.5.1 (arm64)
  • Python version: 3.9.13 (main, May 24 2022, 21:13:51) [Clang 13.1.6 (clang-1316.0.21.2)] (64-bit runtime)
  • Python platform: macOS-12.5.1-arm64-arm-64bit
  • CPU: Apple M1

this tiny script works for me : https://gist.github.com/jzhang533/e19404f6879c8f4f9e73e02eb6a49d9d

jzhang533 avatar Mar 11 '24 03:03 jzhang533

macos intel也不行。paddle和paddleocr都能装上,但是shapely报错 image

LmYjQ avatar Mar 11 '24 08:03 LmYjQ

@LmYjQ What version of PyMuPDF do you have?

I found out where my problem is but I don't know yet how to fix it.

R4Ajeti avatar Mar 11 '24 10:03 R4Ajeti

My problem is that I cannot install PyMuPDF version 1.20.2 as @jzhang533 suggested on his req: pip install --verbose PyMuPDF==1.20.2 > pip_install_log.txt 2>&1

My full logs are here: pip_install_log.txt

More info about: brew info mupdf swig freetype are here:

==> mupdf: stable 1.23.11 (bottled), HEAD Lightweight PDF and XPS viewer https://mupdf.com/ Conflicts with: mupdf-tools (because mupdf and mupdf-tools install the same binaries) /opt/homebrew/Cellar/mupdf/1.23.11 (107 files, 48.3MB) * Poured from bottle using the formulae.brew.sh API on 2024-03-11 at 05:11:28 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/m/mupdf.rb License: AGPL-3.0-or-later ==> Dependencies Build: pkg-config ✔ Required: freetype ✔, gumbo-parser ✔, harfbuzz ✔, jbig2dec ✔, jpeg-turbo ✔, mujs ✔, openjpeg ✔, openssl@3 ✔ ==> Options --HEAD Install HEAD version ==> Analytics install: ... install-on-request: ... build-error: 0 ..

==> swig: stable 4.2.1 (bottled), HEAD Generate scripting interfaces to C/C++ code https://www.swig.org/ /opt/homebrew/Cellar/swig/4.2.1 (829 files, 5.7MB) * Poured from bottle using the formulae.brew.sh API on 2024-03-11 at 05:03:14 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/s/swig.rb License: GPL-3.0-or-later ==> Dependencies Required: pcre2 ✔ ==> Options --HEAD Install HEAD version ==> Analytics install: ... install-on-request: ... build-error: 21 ...

==> freetype: stable 2.13.2 (bottled) Software library to render fonts https://www.freetype.org/ /opt/homebrew/Cellar/freetype/2.13.2 (67 files, 2.4MB) * Poured from bottle using the formulae.brew.sh API on 2024-02-10 at 20:33:37 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/f/freetype.rb License: FTL ==> Dependencies Build: pkg-config ✔ Required: libpng ✔ ==> Analytics install: ... install-on-request: ... build-error: 0 ...

R4Ajeti avatar Mar 11 '24 12:03 R4Ajeti

NEW UPDATES:

I did debug the error on this package paddleocr==2.7.0.3 The error doesn't seems to be on PyMuPDF==1.20.2 bcs i dissabled the import of this library completely on debug but same error remains (it was only on two files "utility.py" and "pdf2word.py").

env6/lib/python3.12/site-packages/paddleocr/tools/infer/predict_det.py -> TextDetector -> call -> self.predictor.run() Line 233 makes the program stuck where inference.create_predictor(config) more specificlly predictor is part of inference from paddle

PS: I suspect the problem lies on build config and paddle inference is not able to deal with it. @jzhang533 Can you pls check what I added above probably you know any fix or work around how i can make it work at least on my development environment (on my laptop)

R4Ajeti avatar Mar 11 '24 14:03 R4Ajeti

CONFIRMED: I can confirm that paddlepaddle does not work on apple M3 pro

WHAT I TRIED: All possibilities of following python interpreter version and paddle package version: paddlepaddle==2.4.2 paddlepaddle==2.5.0 paddlepaddle==2.6.0 Python 3.9.18 Python 3.10.13 Python 3.12.1

The following code is on how I tested it each time and it has the same result and the same problem: "stuckkkkk 4ever".

from paddle import inference
import numpy as np

if __name__ == "__main__":
    print("Hello, World!")

    # modeFilePath = 'models/en_PP-OCRv3_rec_infer/inference.pdmodel'
    # parmsFilePath = 'models/en_PP-OCRv3_rec_infer/inference.pdiparams'

    modeFilePath = 'models/en_PP-OCRv3_det_infer/inference.pdmodel'
    parmsFilePath = 'models/en_PP-OCRv3_det_infer/inference.pdiparams'


    

    # Load the inference model
    config = inference.Config(modeFilePath, parmsFilePath)
    predictor = inference.create_predictor(config)

    # Prepare input data
    input_data = np.random.rand(1, 3, 224, 224).astype(np.float32)  # Example input shape for an image classification model

    # config.set_cpu_math_library_num_threads(5)
    # config.switch_use_feed_fetch_ops(False)
    # config.switch_ir_optim(True)
    
    # Set input tensor
    input_names = predictor.get_input_names()
    input_tensor = predictor.get_input_handle(input_names[0])
    input_tensor.copy_from_cpu(input_data)

    # Run inference
    predictor.run()

    # Get output tensor
    output_names = predictor.get_output_names()
    output_tensor = predictor.get_output_handle(output_names[0])
    output_data = output_tensor.copy_to_cpu()

    # Process the output data as needed
    print("Output prediction:", output_data)

R4Ajeti avatar Mar 11 '24 16:03 R4Ajeti

@R4Ajeti thanks for narrow down this issue. @XieYunshen is working on reproducing it.

jzhang533 avatar Mar 12 '24 02:03 jzhang533

while running locally in bazel sandboxed environment, getting segfault

related

  • #11588
  • #11079

environment

  • macos 14.4 m1 pro
  • python 3.11.7
  • absl-py==2.1.0
  • paddleocr==2.7.0.3
  • paddlepaddle==2.6.0
  • pymupdf==1.21.0

source

from absl import app
from absl import flags
from paddleocr import PaddleOCR
import paddle

_IMAGE_URI = flags.DEFINE_string("image_uri", None, "URI of the image to process.")


def main(argv: list[str]) -> None:
    if len(argv) > 1:
        raise ValueError("too many arguments")
    paddle.utils.run_check()
    ocr = PaddleOCR(use_angle_cls=True, lang="en")
    res = ocr.ocr(_IMAGE_URI.value)
    print(res)


if __name__ == "__main__":
    app.run(main)

output

# equivalent to `python3 run main.py --image_uri=...`
~/Projects/xat> bazel run //paddle_ocr -- --image_uri="https://raw.githubusercontent.com/PaddlePaddle/PaddleOCR/69832ab5326c6db614af6fb74b530aeae1c9b80e/doc/imgs_en/254.jpg"
Running verify PaddlePaddle program ...
I0313 22:24:39.217947 4112169664 program_interpreter.cc:212] New Executor is Running.
I0313 22:24:39.337317 4112169664 interpreter_util.cc:624] Standalone Executor is Used.
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0313 22:24:39.338956 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339063 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339191 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339197 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339252 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339257 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339318 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339483 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339488 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339552 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339557 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339558 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339589 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339592 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339594 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339753 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339802 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339825 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339849 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339865 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339892 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339919 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339936 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.339953 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340008 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340013 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340015 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340016 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340018 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340020 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340021 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340087 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340092 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340094 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340095 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340097 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340098 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
I0313 22:24:39.340101 4112169664 kernel_dispatch.h:102] Get BackendSet from tensor
PaddlePaddle works well on 1 CPU.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
[2024/03/13 22:24:39] 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='/Users/lev1ty/.paddleocr/whl/det/en/en_PP-OCRv3_det_infer', 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='/Users/lev1ty/.paddleocr/whl/rec/en/en_PP-OCRv4_rec_infer', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_batch_num=6, max_text_length=25, rec_char_dict_path='/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/paddle_ocr/paddle_ocr.runfiles/rules_python~~pip~pip_311_paddleocr/site-packages/paddleocr/ppocr/utils/en_dict.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='/Users/lev1ty/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer', 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='en', det=True, rec=True, type='ocr', ocr_version='PP-OCRv4', structure_version='PP-StructureV2')
100%|█████████████████████████████████████████████████████████████████████████████| 65.2k/65.2k [00:00<00:00, 11.1MiB/s]
Fatal Python error: Segmentation fault

Thread 0x0000000343507000 (most recent call first):
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/external/rules_python~~python~python_3_11_7_aarch64-apple-darwin/lib/python3.11/threading.py", line 331 in wait
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/external/rules_python~~python~python_3_11_7_aarch64-apple-darwin/lib/python3.11/threading.py", line 629 in wait
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/paddle_ocr/paddle_ocr.runfiles/rules_python~~pip~pip_311_tqdm/site-packages/tqdm/_monitor.py", line 60 in run
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/external/rules_python~~python~python_3_11_7_aarch64-apple-darwin/lib/python3.11/threading.py", line 1045 in _bootstrap_inner
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/external/rules_python~~python~python_3_11_7_aarch64-apple-darwin/lib/python3.11/threading.py", line 1002 in _bootstrap

Current thread 0x00000001f51abac0 (most recent call first):
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/paddle_ocr/paddle_ocr.runfiles/rules_python~~pip~pip_311_paddleocr/site-packages/paddleocr/tools/infer/predict_det.py", line 245 in __call__
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/paddle_ocr/paddle_ocr.runfiles/rules_python~~pip~pip_311_paddleocr/site-packages/paddleocr/tools/infer/predict_system.py", line 76 in __call__
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/paddle_ocr/paddle_ocr.runfiles/rules_python~~pip~pip_311_paddleocr/site-packages/paddleocr/paddleocr.py", line 661 in ocr
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/paddle_ocr/paddle_ocr.runfiles/_main/paddle_ocr/main.py", line 14 in main
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/paddle_ocr/paddle_ocr.runfiles/rules_python~~pip~pip_311_absl_py/site-packages/absl/app.py", line 254 in _run_main
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/paddle_ocr/paddle_ocr.runfiles/rules_python~~pip~pip_311_absl_py/site-packages/absl/app.py", line 308 in run
  File "/private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/paddle_ocr/paddle_ocr.runfiles/_main/paddle_ocr/main.py", line 19 in <module>

Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, google._upb._message, cython.cimports.libc.math, PIL._imaging, PIL._imagingft, shapely.lib, shapely._geos, shapely._geometry_helpers, pyclipper._pyclipper, skimage._shared.geometry, scipy._lib._ccallback_c, scipy.ndimage._nd_image, scipy.special._ufuncs_cxx, scipy.special._ufuncs, scipy.special._specfun, scipy.special._comb, scipy.linalg._fblas, scipy.linalg._flapack, scipy.linalg.cython_lapack, scipy.linalg._cythonized_array_utils, scipy.linalg._solve_toeplitz, scipy.linalg._flinalg, scipy.linalg._decomp_lu_cython, scipy.linalg._matfuncs_sqrtm_triu, scipy.linalg.cython_blas, scipy.linalg._matfuncs_expm, scipy.linalg._decomp_update, scipy.sparse._sparsetools, _csparsetools, scipy.sparse._csparsetools, scipy.sparse.linalg._dsolve._superlu, scipy.sparse.linalg._eigen.arpack._arpack, scipy.sparse.csgraph._tools, scipy.sparse.csgraph._shortest_path, scipy.sparse.csgraph._traversal, scipy.sparse.csgraph._min_spanning_tree, scipy.sparse.csgraph._flow, scipy.sparse.csgraph._matching, scipy.sparse.csgraph._reordering, scipy.special._ellip_harm_2, _ni_label, scipy.ndimage._ni_label, skimage.measure._ccomp, _skeletonize_3d_cy, skimage.morphology._skeletonize_3d_cy, skimage.morphology._skeletonize_cy, scipy.spatial._ckdtree, scipy._lib.messagestream, scipy.spatial._qhull, scipy.spatial._voronoi, scipy.spatial._distance_wrap, scipy.spatial._hausdorff, scipy.spatial.transform._rotation, skimage.measure._pnpoly, skimage.morphology._convex_hull, skimage.morphology._grayreconstruct, skimage.morphology._extrema_cy, skimage.morphology._flood_fill_cy, skimage.morphology._max_tree, scipy.optimize._minpack2, scipy.optimize._group_columns, scipy.optimize._trlib._trlib, scipy.optimize._lbfgsb, _moduleTNC, scipy.optimize._moduleTNC, scipy.optimize._cobyla, scipy.optimize._slsqp, scipy.optimize._minpack, scipy.optimize._lsq.givens_elimination, scipy.optimize._zeros, scipy.optimize._highs.cython.src._highs_wrapper, scipy.optimize._highs._highs_wrapper, scipy.optimize._highs.cython.src._highs_constants, scipy.optimize._highs._highs_constants, scipy.linalg._interpolative, scipy.optimize._bglu_dense, scipy.optimize._lsap, scipy.optimize._direct, scipy.integrate._odepack, scipy.integrate._quadpack, scipy.integrate._vode, scipy.integrate._dop, scipy.integrate._lsoda, scipy.special.cython_special, scipy.stats._stats, scipy.stats.beta_ufunc, scipy.stats._boost.beta_ufunc, scipy.stats.binom_ufunc, scipy.stats._boost.binom_ufunc, scipy.stats.nbinom_ufunc, scipy.stats._boost.nbinom_ufunc, scipy.stats.hypergeom_ufunc, scipy.stats._boost.hypergeom_ufunc, scipy.stats.ncf_ufunc, scipy.stats._boost.ncf_ufunc, scipy.stats.ncx2_ufunc, scipy.stats._boost.ncx2_ufunc, scipy.stats.nct_ufunc, scipy.stats._boost.nct_ufunc, scipy.stats.skewnorm_ufunc, scipy.stats._boost.skewnorm_ufunc, scipy.stats.invgauss_ufunc, scipy.stats._boost.invgauss_ufunc, scipy.interpolate._fitpack, scipy.interpolate.dfitpack, scipy.interpolate._bspl, scipy.interpolate._ppoly, scipy.interpolate.interpnd, scipy.interpolate._rbfinterp_pythran, scipy.interpolate._rgi_cython, scipy.stats._biasedurn, scipy.stats._levy_stable.levyst, scipy.stats._stats_pythran, scipy._lib._uarray._uarray, scipy.stats._ansari_swilk_statistics, scipy.stats._sobol, scipy.stats._qmc_cy, scipy.stats._mvn, scipy.stats._rcont.rcont, scipy.stats._unuran.unuran_wrapper, skimage.segmentation._felzenszwalb_cy, scipy.cluster._vq, scipy.cluster._hierarchy, scipy.cluster._optimal_leaf_ordering, skimage.segmentation._slic, skimage.segmentation._quickshift_cy, skimage.segmentation._watershed_cy, scipy.io.matlab._mio_utils, scipy.io.matlab._streams, scipy.io.matlab._mio5_utils, lmdb.cpython, charset_normalizer.md (total: 144)
Error: bazel exited with exit code: -1
~/Projects/xat> /private/var/tmp/_bazel_lev1ty/3b8fb8eaf07df7eb5946fd70f125660d/external/rules_python~~python~python_3_11_7_aarch64-apple-darwin/lib/python3.11/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
                                                               warnings.warn('resource_tracker: There appear to be %d

Lev1ty avatar Mar 14 '24 02:03 Lev1ty

@jzhang533 - I also noticed that it is not running on Google Colab.

Version: paddleocr==2.7.0.3 paddlepaddle==2.6.0

My code: from paddleocr import PaddleOCR ocr = PaddleOCR()

Error:

Timestamp Level Message Apr 2, 2024, 6:02:09 PM WARNING WARNING:root:kernel 36de8196-23d4-4805-8f1a-c9acb66ef70a restarted Apr 2, 2024, 6:02:09 PM INFO KernelRestarter: restarting kernel (1/5), keep random ports Apr 2, 2024, 6:02:09 PM WARNING [SignalInfo: *** SIGILL (@0x7d9575a1e86a) received by PID 2642 (TID 0x7d95c16af000) from PID 1973545066 ] Apr 2, 2024, 6:02:09 PM WARNING [TimeInfo: *** Aborted at 1712061128 (unix time) try "date -d @1712061128" if you are using GNU date ] Apr 2, 2024, 6:02:09 PM WARNING FatalError: Illegal instruction is detected by the operating system. Apr 2, 2024, 6:02:09 PM WARNING ---------------------- Apr 2, 2024, 6:02:09 PM WARNING Error Message Summary: Apr 2, 2024, 6:02:09 PM WARNING ---------------------- Apr 2, 2024, 6:02:09 PM WARNING 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)>) Apr 2, 2024, 6:02:09 PM WARNING 9 paddle::framework::ir::SelfAttentionFusePass::ApplyImpl(paddle::framework::ir::Graph*) const

avakashsahoo-spry avatar Apr 02 '24 12:04 avakashsahoo-spry

Here's a full lldb backtrace from an M1 Pro, Python 3.11.

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000180dcc904 libsystem_platform.dylib`_platform_strlen + 4
    frame #1: 0x000000010f0c58d4 libpaddle.so`google::SymbolizeAndDemangle(void*, char*, int) + 52
    frame #2: 0x000000010f0c7f10 libpaddle.so`google::(anonymous namespace)::DumpStackFrameInfo(char const*, void*) + 68
    frame #3: 0x000000010f0c7154 libpaddle.so`google::(anonymous namespace)::FailureSignalHandler(int, __siginfo*, void*) + 2040
    frame #4: 0x0000000180dcf584 libsystem_platform.dylib`_sigtramp + 56
    frame #5: 0x000000010940f6e4 libphi.dylib`sgemm_nn + 600
    frame #6: 0x000000010940b480 libphi.dylib`cblas_sgemm + 664
    frame #7: 0x0000000107ca5f14 libphi.dylib`void phi::funcs::Blas<phi::CPUContext>::MatMul<float>(phi::DenseTensor const&, bool, phi::DenseTensor const&, bool, float, phi::DenseTensor*, float) const + 476
    frame #8: 0x0000000107eec0d4 libphi.dylib`void phi::ConvKernelImpl<float, phi::CPUContext>(phi::CPUContext const&, phi::DenseTensor const&, phi::DenseTensor const&, std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, phi::DenseTensor*) + 2104
    frame #9: 0x0000000107eed3a4 libphi.dylib`phi::KernelImpl<void (*)(phi::CPUContext const&, phi::DenseTensor const&, phi::DenseTensor const&, std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::vector<int, std::__1::allocator<int>> const&, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, phi::DenseTensor*), &void phi::ConvKernel<float, phi::CPUContext>(phi::CPUContext const&, phi::DenseTensor const&, phi::DenseTensor const&, std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::vector<int, std::__1::allocator<int>> const&, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, phi::DenseTensor*)>::Compute(phi::KernelContext*) + 244
    frame #10: 0x0000000113b78084 libpaddle.so`paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, phi::Place const&, paddle::framework::RuntimeContext*) const + 5152
    frame #11: 0x0000000113b76b60 libpaddle.so`paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, phi::Place const&) const + 440
    frame #12: 0x0000000113b70b5c libpaddle.so`paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, phi::Place const&) + 400
    frame #13: 0x0000000112456038 libpaddle.so`paddle::framework::NaiveExecutor::Run() + 512
    frame #14: 0x000000010f23f0f8 libpaddle.so`paddle::AnalysisPredictor::ZeroCopyRun() + 320
    frame #15: 0x000000010ed6d60c libpaddle.so`void pybind11::cpp_function::initialize<paddle::pybind::(anonymous namespace)::BindPaddleInferPredictor(pybind11::module_*)::$_21, void, paddle_infer::Predictor&, pybind11::name, pybind11::is_method, pybind11::sibling>(paddle::pybind::(anonymous namespace)::BindPaddleInferPredictor(pybind11::module_*)::$_21&&, void (*)(paddle_infer::Predictor&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::'lambda'(pybind11::detail::function_call&)::__invoke(pybind11::detail::function_call&) + 88
    frame #16: 0x000000010e9ba7bc libpaddle.so`pybind11::cpp_function::dispatcher(_object*, _object*, _object*) + 3620
    frame #17: 0x000000010343fda8 libpython3.11.dylib`cfunction_call + 84
    frame #18: 0x00000001033f4aec libpython3.11.dylib`_PyObject_MakeTpCall + 344
    frame #19: 0x00000001034d4dcc libpython3.11.dylib`_PyEval_EvalFrameDefault + 33812
    frame #20: 0x00000001034cc918 libpython3.11.dylib`_PyEval_Vector + 200
    frame #21: 0x00000001033f4904 libpython3.11.dylib`_PyObject_FastCallDictTstate + 272
    frame #22: 0x00000001033f5654 libpython3.11.dylib`_PyObject_Call_Prepend + 160
    frame #23: 0x0000000103460990 libpython3.11.dylib`slot_tp_call + 184
    frame #24: 0x00000001033f4aec libpython3.11.dylib`_PyObject_MakeTpCall + 344
    frame #25: 0x00000001034d4dcc libpython3.11.dylib`_PyEval_EvalFrameDefault + 33812
    frame #26: 0x00000001034cc7e8 libpython3.11.dylib`PyEval_EvalCode + 272
    frame #27: 0x000000010351f6a0 libpython3.11.dylib`run_mod + 152
    frame #28: 0x000000010351db94 libpython3.11.dylib`_PyRun_SimpleFileObject + 852
    frame #29: 0x000000010351d61c libpython3.11.dylib`_PyRun_AnyFileObject + 160
    frame #30: 0x000000010353cd4c libpython3.11.dylib`Py_RunMain + 1848
    frame #31: 0x000000010353d0fc libpython3.11.dylib`pymain_main + 324
    frame #32: 0x000000010353d19c libpython3.11.dylib`Py_BytesMain + 40
    frame #33: 0x0000000180a160e0 dyld`start + 2360

Paddle version:

$ pip freeze | grep paddle
paddleocr==2.7.3
paddlepaddle==2.6.1

Inference command:

paddleocr --image_dir=images/ --use_angle_cls=false --use_gpu=false --lang en

astahlman avatar Apr 10 '24 13:04 astahlman

I suspect this is related to blas library paddlepaddle is using on mac. it's using openblas, and pinned to version 0.3.13, which is a release of openblas at 2022-12, there is no mac m1 on the market at that time.

Probably we can upgrade openblas to the latest version, and see what will happen.

Another better option is using Apple's proprietary BLAS implementation, it should be much more faster than using openblas, since Apple's implementation is using accelerator on M1. But this requires lots of work.

jzhang533 avatar Apr 11 '24 03:04 jzhang533

I'd like to subscribe to this issue too :)

Apple M2 on MBA 15". It just hangs.

paddleocr==2.7.3
paddlepaddle==2.6.1

dchaplinsky avatar May 06 '24 18:05 dchaplinsky

Same here:

paddleocr==2.7.3
paddlepaddle==2.6.1

santibasis avatar May 08 '24 12:05 santibasis

Also experiencing this on M1 Pro

alexisdrakopoulos avatar May 09 '24 14:05 alexisdrakopoulos

if you are still suffering from this issue, please uninstall your local paddlepaddle, and try nightly build:

python -m pip install paddlepaddle==0.0.0 -f https://www.paddlepaddle.org.cn/whl/mac/cpu/develop.html

I figured out how to use Apple's BLAS library to replace openblas on a boring meeting, and created this PR: https://github.com/PaddlePaddle/Paddle/pull/64408 .

jzhang533 avatar May 20 '24 10:05 jzhang533

if you are still suffering from this issue, please uninstall your local paddlepaddle, and try nightly build:

python -m pip install paddlepaddle==0.0.0 -f https://www.paddlepaddle.org.cn/whl/mac/cpu/develop.html

I figured out how to use Apple's BLAS library to replace openblas on a boring meeting, and created this PR: PaddlePaddle/Paddle#64408 .

good job, it works, any update now?

Hu-Wentao avatar Jun 08 '24 18:06 Hu-Wentao

If the problem still exists, maybe you could refer this link

SWHL avatar Jun 13 '24 12:06 SWHL