Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

PaddleOCR Freezes on M2 MacOS Ventura version 13.5 #11079

Closed
pranay-009 opened this issue Oct 13, 2023 · 26 comments
Closed

PaddleOCR Freezes on M2 MacOS Ventura version 13.5 #11079

pranay-009 opened this issue Oct 13, 2023 · 26 comments
Assignees
Labels
apple silicon this issue happens on apple sillicon needs investigation this issue needs investigation to either narrow down, or clarify triaged this issue has been looked, and triaged.

Comments

@pranay-009
Copy link

I installed

  • PyMuPDF-1.20.2 and paddleocr-2.7.0 and PaddlePaddle 2.3.2
  • I was using python 3.8.18
  • System Information :Mac M2 MacOS Ventura version 13.5

I had to force and stop the process

code sample

from paddleocr import PaddleOCR
ocr = PaddleOCR(use_angle_cls=True, lang='en') # need to run only once to download and load model into memory
img_path = '/Users/pranaysaha/Developer/OCR/sample.jpeg'
result = ocr.ocr(img_path, cls=True) 
@pavan5849
Copy link

I'm also facing same issue
My configuration:
Python 3.9.6
Macos: Sonoma 14.1.1
Apple M2 pro
imageio==2.10.1
opencv-contrib-python==4.6.0.66
opencv-python-headless==4.6.0.66
protobuf==3.20.0
paddleocr==2.7.0.3
paddlepaddle==2.4.0

@nvinayvarma189
Copy link

I'm also facing same issue. My configuration:

Python 3.10.12
Macos: Sonoma 14.1.2
Apple M2 pro

opencv-contrib-python==4.6.0.66
opencv-python==4.6.0.66
protobuf==4.25.1
paddleocr==2.7.0.3
paddlepaddle==2.5.1
pymupdf==1.20.0

I tried the same code as @pranay-009 and the execution freezes after this:

[2023/12/05 15:17:08] 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/roronoa/.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/roronoa/.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='/Users/roronoa/.local/share/virtualenvs/hemkund-backend-w6cFaI3p/lib/python3.10/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/roronoa/.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')

@sanduluca
Copy link

sanduluca commented Dec 19, 2023

I have same issue. Does anyone have a solution for this ?

Apple M2 Pro, 16 GB, Sonoma 14.0
Python 3.11.6

numpy==1.26.2
opencv-contrib-python==4.8.1.78
opencv-python==4.8.1.78
paddleocr==2.6.0.1
paddlepaddle==2.5.2
pandas==2.1.4
Pillow==10.1.0
protobuf==4.23.4
PyMuPDF==1.21.1

@PterX
Copy link

PterX commented Dec 21, 2023

I have same issue. Does anyone have a solution for this ?

@linjson
Copy link

linjson commented Jan 17, 2024

I have same issue,

@BB86818BB
Copy link

I have same issue,
m1 pro
paddlepaddle 2.6.0
paddleocr 2.6.0.1
Python 3.8.18
opencv-contrib-python 4.6.0.66/4.9.0.80
opencv-python 4.6.0.66/4.9.0.80

@linjson
Copy link

linjson commented Jan 25, 2024

先用 rapidocr平替吧,用 onnx推理,模型还是用paddle的,在m2上可用

@vikasr111
Copy link

I am facing the same issue on Macbook M3 Pro.
paddlepaddle==2.6.0
paddleocr==2.7.0.3

Macos: Sonoma 14.1.2
Python 3.10.13 (But it doesn't matter, tested on multiple Python version).
I hope there's some solution to running this on Mac with Apple Silicon.

@benx13
Copy link

benx13 commented Feb 29, 2024

same issue running on M1 Pro

@jzhang533
Copy link
Collaborator

cc: @michaelowenliu @dyning @tink2123
This should be a high-priority issue that needs the maintainers' attention.

@jzhang533
Copy link
Collaborator

I can run the following script on my Apple M1, macOS Monterey, python 3.9.13 without freezing issue.

from paddleocr import PaddleOCR
ocr = PaddleOCR(use_angle_cls=True, lang='en')
img_path = './1.jpeg'
result = ocr.ocr(img_path, cls=True)

I have the following packages installed:

paddleocr 2.7.0.3
paddlepaddle 2.6.0

I'm unclear about the differences between the various M-series chips, but I'm hoping they'll be compatible.
Would anyone be willing to upgrade PaddlePaddle to version 2.6.0 and share the result?

@benx13
Copy link

benx13 commented Mar 1, 2024

I can run the following script on my Apple M1, macOS Monterey, python 3.9.13 without freezing issue.

from paddleocr import PaddleOCR
ocr = PaddleOCR(use_angle_cls=True, lang='en')
img_path = './1.jpeg'
result = ocr.ocr(img_path, cls=True)

I have the following packages installed:

paddleocr 2.7.0.3 paddlepaddle 2.6.0

I'm unclear about the differences between the various M-series chips, but I'm hoping they'll be compatible. Would anyone be willing to upgrade PaddlePaddle to version 2.6.0 and share the result?

I've got
python 3.9.6
Sonoma 14.2.1

paddleocr 2.7.0.3
paddlepaddle 2.6.0
PyMuPDF 1.20.2

still freezing

@sunzhongkai588
Copy link

I've got python 3.9.6 Sonoma 14.2.1

paddleocr 2.7.0.3 paddlepaddle 2.6.0 PyMuPDF 1.20.2

still freezing

I'm using Python 3.9.13 and Sonoma 14.0, with all other package versions matching yours.

I can run the program successfully. It's possible there may be an issue with your image. Could you share an example image?

@benx13
Copy link

benx13 commented Mar 6, 2024

I've got python 3.9.6 Sonoma 14.2.1
paddleocr 2.7.0.3 paddlepaddle 2.6.0 PyMuPDF 1.20.2
still freezing

I'm using Python 3.9.13 and Sonoma 14.0, with all other package versions matching yours.

I can run the program successfully. It's possible there may be an issue with your image. Could you share an example image?

you can use:
img_path = './imgs_en/img_12.jpg'
from the official PaddleOCR repository
img_12

@jzhang533
Copy link
Collaborator

you can use:
img_path = './imgs_en/img_12.jpg'
from the official PaddleOCR repository

still can't reproduce this freezing issue, can you share result of running this :
python -mplatform 'platform.platform()'

@R4Ajeti
Copy link

R4Ajeti commented Mar 11, 2024

@jzhang533 I have same issue as @benx13
apple M3 pro
python version: 3.12.1
paddleocr==2.6.0.1
paddlepaddle==2.6.0
PyMuPDF==1.23.26
opencv-contrib-python==4.6.0.66
opencv-python==4.6.0.66

python -mplatform 'platform.platform()'
gives this one:
macOS-14.4-arm64-arm-64bit

@kilimchoi
Copy link

kilimchoi commented Mar 16, 2024

@jzhang533 experiencing the same thing.
I have:

Apple M1 Ventura 13.1
Python 3.10.12
paddleocr==2.7.0.3
paddlepaddle==2.6.0
pymupdf==1.20.2

python -mplatform 'platform.platform()' returns: macOS-13.1-arm64-arm-64bit

@benx13
Copy link

benx13 commented Mar 17, 2024

you can use:
img_path = './imgs_en/img_12.jpg'
from the official PaddleOCR repository

still can't reproduce this freezing issue, can you share result of running this : python -mplatform 'platform.platform()'

python -mplatform 'platform.platform()'

@jzhang533 it gives:
macOS-14.2.1-arm64-arm-64bit
references:
python 3.9.6
paddleocr 2.7.0.3
paddlepaddle 2.6.0
PyMuPDF 1.20.2
M1 Pro chip

@avakashsahoo-spry
Copy link

macOS-14.1.2-arm64-arm-64bit
image
Getting stuck in my mac M2 as well

@benx13
Copy link

benx13 commented Mar 27, 2024

@jzhang533 surprisingly, on a different Python version, it worked for me technically on the default version so the way I had it set up is I installed it on python 3.9 which is not my default Python my default is 3.12. When I installed it on python 3.12 it surprisingly works no issues.

@avakashsahoo-spry
Copy link

@jzhang533 surprisingly, on a different Python version, it worked for me technically on the default version so the way I had it set up is I installed it on python 3.9 which is not my default Python my default is 3.12. When I installed it on python 3.12 it surprisingly works no issues.

Gets stuck on 3.12 version as well

@R4Ajeti
Copy link

R4Ajeti commented Mar 27, 2024

@jzhang533 surprisingly, on a different Python version, it worked for me technically on the default version so the way I had it set up is I installed it on python 3.9 which is not my default Python my default is 3.12. When I installed it on python 3.12 it surprisingly works no issues.

Gets stuck on 3.12 version as well

Ofc it does, I have debugged it fully and the conclusion: problem lies on paddlepaddle inference not on paddle ocr check this thread for more info:
#11706

@vikasr111
Copy link

For all who are still facing this issue, I have managed to run to successfully on Mac M3 Pro using Docker. Here's the Dockerfile you can use to build and run PaddleOCR. Hope this helps.

# Base Stage: Install common dependencies
FROM python:3.10-slim-bullseye

# Set the working directory in the container to /app
WORKDIR /app

# Set PYTHONPATH to include the /app directory
ENV PYTHONPATH="${PYTHONPATH}:/app"

# Add the rest of the current directory contents into the container at /app
COPY . .

# Install dependencies for OCR
RUN apt-get update \
    && apt-get install --no-install-recommends -y ffmpeg libsm6 libxext6 build-essential \
    # Install your Python packages that require compilation here
    && pip install --no-cache-dir python-dotenv==1.0.1 \
    && pip install --no-cache-dir paddlepaddle==2.6.0 \
    && pip install --no-cache-dir paddleocr==2.7.0.3 \
    # Cleanup: Remove build-essential and cleanup apt cache in the same command
    && apt-get purge -y build-essential \
    && apt-get autoremove -y \
    && rm -rf /var/lib/apt/lists/* /root/.cache/pip

To build and run this Docker image:

docker build -t paddle-ocr
docker exec -it paddle-ocr /bin/bash

@jinbinhan
Copy link

同样在M2上卡住了

@fuji246
Copy link

fuji246 commented Apr 4, 2024

For all who are still facing this issue, I have managed to run to successfully on Mac M3 Pro using Docker. Here's the Dockerfile you can use to build and run PaddleOCR. Hope this helps.

# Base Stage: Install common dependencies
FROM python:3.10-slim-bullseye

# Set the working directory in the container to /app
WORKDIR /app

# Set PYTHONPATH to include the /app directory
ENV PYTHONPATH="${PYTHONPATH}:/app"

# Add the rest of the current directory contents into the container at /app
COPY . .

# Install dependencies for OCR
RUN apt-get update \
    && apt-get install --no-install-recommends -y ffmpeg libsm6 libxext6 build-essential \
    # Install your Python packages that require compilation here
    && pip install --no-cache-dir python-dotenv==1.0.1 \
    && pip install --no-cache-dir paddlepaddle==2.6.0 \
    && pip install --no-cache-dir paddleocr==2.7.0.3 \
    # Cleanup: Remove build-essential and cleanup apt cache in the same command
    && apt-get purge -y build-essential \
    && apt-get autoremove -y \
    && rm -rf /var/lib/apt/lists/* /root/.cache/pip

To build and run this Docker image:

docker build -t paddle-ocr
docker exec -it paddle-ocr /bin/bash

not working

root@e310947389a8:/app# paddleocr --image_dir /mnt/UML\ diagram.jpg --lang en --use_gpu false
download https://paddleocr.bj.bcebos.com/PP-OCRv3/english/en_PP-OCRv3_det_infer.tar to /root/.paddleocr/whl/det/en/en_PP-OCRv3_det_infer/en_PP-OCRv3_det_infer.tar
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4.00M/4.00M [00:09<00:00, 422kiB/s]


--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
0   inflateReset2

----------------------
Error Message Summary:
----------------------
FatalError: `Segmentation fault` is detected by the operating system.
  [TimeInfo: *** Aborted at 1712249711 (unix time) try "date -d @1712249711" if you are using GNU date ***]
  [SignalInfo: *** SIGSEGV (@0x18) received by PID 39 (TID 0xffffa023ed40) from PID 24 ***]

Segmentation fault

@jzhang533 jzhang533 added triaged this issue has been looked, and triaged. needs investigation this issue needs investigation to either narrow down, or clarify apple silicon this issue happens on apple sillicon labels Apr 10, 2024
@SWHL
Copy link
Collaborator

SWHL commented Jun 13, 2024

如果问题依然存在,可以参考link

If the problem still exists, you could try to solve it according this link

@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Jun 13, 2024
@SWHL SWHL converted this issue into discussion #13062 Jun 13, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
apple silicon this issue happens on apple sillicon needs investigation this issue needs investigation to either narrow down, or clarify triaged this issue has been looked, and triaged.
Projects
None yet
Development

No branches or pull requests