PaddleOCR icon indicating copy to clipboard operation
PaddleOCR copied to clipboard

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

Open j0sephsasson opened this issue 1 year ago • 24 comments

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

j0sephsasson avatar Jan 23 '24 21:01 j0sephsasson

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.

OussamaBATOUCHE avatar Jan 28 '24 21:01 OussamaBATOUCHE

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.

j0sephsasson avatar Jan 29 '24 16:01 j0sephsasson

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 avatar Jan 30 '24 09:01 OussamaBATOUCHE

@tink2123 can you please help here ?!

OussamaBATOUCHE avatar Jan 30 '24 13:01 OussamaBATOUCHE

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

yiyedaren avatar Jan 31 '24 01:01 yiyedaren

Any solution?

matheus-fonseca avatar Jan 31 '24 14:01 matheus-fonseca

Any solution?+1

qingyuanxingsi avatar Feb 02 '24 07:02 qingyuanxingsi

Same here. downgrade to 2.5.2 do the job

biaji avatar Feb 03 '24 09:02 biaji

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

mapa17 avatar Feb 03 '24 17:02 mapa17

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.

  • CVE-2023-52310
  • CVE-2023-52311
  • CVE-2023-52314

j0sephsasson avatar Feb 05 '24 17:02 j0sephsasson

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 !!!

OussamaBATOUCHE avatar Feb 05 '24 20:02 OussamaBATOUCHE

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?

HarishOsthe avatar Mar 22 '24 07:03 HarishOsthe

@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 avatar Mar 22 '24 16:03 mavel-x

@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

mavel-x avatar Mar 25 '24 10:03 mavel-x

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

funny and strange

jzhang533 avatar Apr 10 '24 08:04 jzhang533

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

ReasonDuan avatar Apr 25 '24 08:04 ReasonDuan

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

evanbattaglia avatar May 11 '24 23:05 evanbattaglia

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

phil-chp avatar May 18 '24 20:05 phil-chp

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 avatar Jul 17 '24 16:07 v3ss0n

--------------------------------------
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

v3ss0n avatar Jul 17 '24 16:07 v3ss0n

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 ***]

zqWu avatar Aug 01 '24 09:08 zqWu

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 ***]

arpanbiswas97 avatar Aug 02 '24 16:08 arpanbiswas97

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

tobwen avatar Aug 10 '24 12:08 tobwen

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

Any update on this?

karanataryn avatar Aug 29 '24 18:08 karanataryn

换paddle3.0beta1试试

GreatV avatar Aug 30 '24 00:08 GreatV

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"

johnlockejrr avatar Sep 02 '24 13:09 johnlockejrr