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)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
42.62k stars 7.67k forks source link

FatalError: `Segmentation fault` is detected by the operating system. #11530

Closed j0sephsasson closed 2 weeks ago

j0sephsasson commented 7 months ago

Hello, I am running into this error when upgrading from 2.5.2 to 2.6.0 - using CPU version.

OussamaBATOUCHE commented 7 months ago

Hello, I am running into this error when upgrading from 2.5.2 to 2.6.0 - using CPU version.

  • 系统环境/System Environment:Linux
  • 版本号/Version: Paddle:2.6.0 PaddleOCR:>=2.0.1
  • 运行指令/Command Code: RUN python3 -m pip install paddlepaddle==2.6.0 -i https://mirror.baidu.com/pypi/simple RUN python -c "from paddleocr import PaddleOCR; PaddleOCR()"
  • 完整报错/Complete Error Message:
22.56 --------------------------------------
22.56 C++ Traceback (most recent call last):
22.56 --------------------------------------
22.56 0   inflateReset2
22.56 
22.56 ----------------------
22.56 Error Message Summary:
22.56 ----------------------
22.56 FatalError: `Segmentation fault` is detected by the operating system.
22.56   [TimeInfo: *** Aborted at 1706042955 (unix time) try "date -d @1706042955" if you are using GNU date ***]
22.56   [SignalInfo: *** SIGSEGV (@0xaaa050337c15) received by PID 7 (TID 0xffff7f7bd020) from PID 1345551381 ***]
22.56 
22.64 Segmentation fault

Hi,

Are you using a Docker container? did you manage to solve this issue?

Thanks.

j0sephsasson commented 7 months ago

Hello @OussamaBATOUCHE , I am using Docker yes. I have not been able to solve this. Thank you in advance for any insight you can provide.

OussamaBATOUCHE commented 7 months ago

Hello @OussamaBATOUCHE , I am using Docker yes. I have not been able to solve this. Thank you in advance for any insight you can provide.

Thanks for the reply, I haven't solved it yet, hopefully, the Paddle guys can help!

OussamaBATOUCHE commented 7 months ago

@tink2123 can you please help here ?!

yiyedaren commented 7 months ago

the same question ,who know that and who can help us?

matheus-fonseca commented 7 months ago

Any solution?

qingyuanxingsi commented 7 months ago

Any solution?+1

biaji commented 7 months ago

Same here. downgrade to 2.5.2 do the job

mapa17 commented 7 months ago

Thank you, I had the same issue and downgrading to 2.5.2 solved it!

j0sephsasson commented 7 months ago

Just to clarify -- yes it works with 2.5.2

However, there are several CVEs identified in 2.5.2 that are solved in 2.6.0

That is the reason I need to upgrade.

OussamaBATOUCHE commented 7 months ago

Just to clarify -- yes it works with 2.5.2

However, there are several CVEs identified in 2.5.2 that are solved in 2.6.0

That is the reason I need to upgrade.

@j0sephsasson it's not working here !!!

HarishOsthe commented 5 months ago

I also had an issue with segfault on any version of paddlepaddle after 2.5.2. I was able to make it work for paddlepaddle==2.6.1 and paddleocr==2.7.0.3 by moving

PaddleOCR(use_angle_cls=True, lang="de", show_log=False)

into ifmain

if __name__ == '__main__':
    PaddleOCR(use_angle_cls=True, lang="de", show_log=False)

in my prefetching script.

No idea why it worked but I hope it helps someone else.

@mavel-x if you can get it run inside docker, can you share the docker file?

mavel-x commented 5 months ago

@HarishOsthe Sorry, it doesn't work for me in Docker any more. I guess I rolled a critical success that one time building the image. I'll update this if I can solve it.

mavel-x commented 5 months ago

@HarishOsthe The shamanism continues. Somehow adding a logger.info(...) line made it stop crashing. I also rebuilt it from scratch with no cache to verify that it wasn't a 0.001% chance occurrence like before. It actually works consistently for me now. No other changes in the code or dependencies produced the same result. I'm sharing my Dockerfile and download script.

Dockerfile

FROM python:3.10-slim

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN apt-get update \
    && apt-get install -y --no-install-recommends libgl1 libgomp1 libglib2.0-0 poppler-utils

RUN useradd -m appuser

WORKDIR /opt/app

COPY requirements.txt /opt/app/
RUN pip install --upgrade pip \
    && pip install --no-cache-dir -r requirements.txt

COPY . /opt/app/
RUN chown -R appuser:appuser /opt/app
USER appuser

RUN python app/fetch_dependency_files.py
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]

fetch_dependency_files.py

"""
Load the files required for PaddleOCR before starting uvicorn workers. Not doing this will cause
all workers to download simultaneously, and some of them will then crash.
"""

from loguru import logger
from paddleocr import PaddleOCR

if __name__ == "__main__":
    # This line is essential for the next one not to cause a segfault.
    # Don't ask why, just trust the process
    logger.info("Downloading PaddleOCR files...")

    PaddleOCR(use_angle_cls=True, lang="german", show_log=False)

versions: paddlepaddle==2.6.1 paddleocr==2.7.0.3

jzhang533 commented 5 months ago

Somehow adding a logger.info(...) line made it stop crashing.

funny and strange

ReasonDuan commented 4 months ago

有没有更新?我也遇到相同的问题,使用docker部署

evanbattaglia commented 4 months ago

Building on mavel-x's findings -- for me, simply adding import loguru was enough to fix the crash. 🤷

phil-chp commented 3 months ago

Working with PaddlePaddle/PaddleOCR thaught me to check chinese articles/docs (https://blog.csdn.net/shuaishishi/article/details/136619380)

I'm not 100% sure I understood the (translated) article correctly, but it seems like PaddlePaddle>=2.4 doesn't like having pytorch installed alongside it. I told my colleague that works with Win11 + WSL2 to uninstall pytorch then reboot and that fixed it for him.

python3 -m pip uninstall torch
v3ss0n commented 1 month ago

Segmentation Fault when trying this to different files :

paddleocr --image_dir ./tests/data/00006737.jpg --lang en --type=structure - Works fine ( from the test dataset) paddleocr --image_dir ./tests/data/OCR.jpg --lang en --type=structure - Seg Fault.

v3ss0n commented 1 month ago
--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
0   deflateReset

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

zsh: segmentation fault (core dumped)  paddleocr --image_dir ./tests/data/OCR.jpg --lang en --type=structure
zqWu commented 1 month ago

same error in docker environment paddleocr 2.8.0 paddlepaddle-gpu 2.5.1

--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
0   paddle::AnalysisPredictor::ZeroCopyRun()
1   paddle::framework::NaiveExecutor::Run()
2   paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, phi::Place const&)
3   paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, phi::Place const&) const
4   paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, phi::Place const&, paddle::framework::RuntimeContext*) const
5   phi::KernelImpl<void (*)(phi::CPUContext const&, phi::DenseTensor const&, phi::DenseTensor const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::string const&, std::vector<int, std::allocator<int> > const&, int, std::string const&, phi::DenseTensor*), &(void phi::ConvKernel<float, phi::CPUContext>(phi::CPUContext const&, phi::DenseTensor const&, phi::DenseTensor const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::string const&, std::vector<int, std::allocator<int> > const&, int, std::string const&, phi::DenseTensor*))>::Compute(phi::KernelContext*)
6   void phi::ConvKernelImpl<float, phi::CPUContext>(phi::CPUContext const&, phi::DenseTensor const&, phi::DenseTensor const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::string const&, int, std::vector<int, std::allocator<int> > const&, std::string const&, phi::DenseTensor*)
7   phi::funcs::Im2ColFunctor<(phi::funcs::ColFormat)0, phi::CPUContext, float>::operator()(phi::CPUContext const&, phi::DenseTensor const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, phi::DenseTensor*, phi::DataLayout)

----------------------
Error Message Summary:
----------------------
FatalError: `Segmentation fault` is detected by the operating system.
  [TimeInfo: *** Aborted at 1722503164 (unix time) try "date -d @1722503164" if you are using GNU date ***]
  [SignalInfo: *** SIGSEGV (@0x7fcd625263e0) received by PID 40 (TID 0x7fd561bd7740) from PID 1649566688 ***]
arpanbiswas97 commented 1 month ago

I am facing the same issue on WSL (Ubuntu) with paddleocr == 2.8.1 paddlepaddle-gpu == 2.6.1

--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
No stack trace in paddle, may be caused by external reasons.

----------------------
Error Message Summary:
----------------------
FatalError: `Segmentation fault` is detected by the operating system.
  [TimeInfo: *** Aborted at 1722615047 (unix time) try "date -d @1722615047" if you are using GNU date ***]
  [SignalInfo: *** SIGSEGV (@0x0) received by PID 16394 (TID 0x7f65d9867440) from PID 0 ***]
tobwen commented 1 month ago

Yeah, same here: WSL (Ubuntu) leads to a SegFault. At least no BSOD :)

karanataryn commented 2 weeks ago

Same issue here, on Debian 12, paddleocr == 2.8.1 paddlepaddle-gpu == 2.6.1

Any update on this?

GreatV commented 2 weeks ago

换paddle3.0beta1试试

johnlockejrr commented 1 week ago

Same here on WSL 2 Ubuntu-22.04, python 3.10. Installing paddle 3.0 beta 1 and paddleocr == 2.8.1 solved the problem.

$ virtualenv PaddleOCR-py3.10 -p python3.10
$ source PaddleOCR-py3.10/bin/activate
$ python3 -m pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu123/
$ pip install "paddleocr>=2.8.1"