Skip to content
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

gpu环境并发请求:RuntimeError: could not execute a primitive #14836

Open
3 tasks done
June-Li opened this issue Mar 11, 2025 · 5 comments
Open
3 tasks done

gpu环境并发请求:RuntimeError: could not execute a primitive #14836

June-Li opened this issue Mar 11, 2025 · 5 comments

Comments

@June-Li
Copy link

June-Li commented Mar 11, 2025

🔎 Search before asking

  • I have searched the PaddleOCR Docs and found no similar bug report.
  • I have searched the PaddleOCR Issues and found no similar bug report.
  • I have searched the PaddleOCR Discussions and found no similar bug report.

🐛 Bug (问题描述)

我用的fastapi(flaskapi也试过,问题一样);
这是fastapi中的代码片段,如果保留async,他其实是单线程(不报错),因为你同时发两个请求,只有一个在处理并且会阻塞另一个请求,也就是另一个请求在排队,如果把async删掉的话,就可以多线程并发处理了,但是会报错,这个报错是从paddleocr传出来的。但是我们的服务是需要多线程的,不能阻塞在那;
@app.post(
"/pdf_parse",
tags=["projects"],
summary="Parse PDF files (supports local files and S3)",
)
async def pdf_parse(
pdf_file: UploadFile = None,
pdf_path: str = None,
parse_method: str = "auto",
is_json_md_dump: bool = False,
output_dir: str = "output",
return_layout: bool = False,
return_info: bool = False,
return_content_list: bool = False,
return_images: bool = False,
):

🏃‍♂️ Environment (运行环境)

How to reproduce the bug | 如何复现
flaskapi或者fastapi部署服务后,同时发两个请求就会出现以上报错

Operating system | 操作系统
Linux

Python version | Python 版本
3.10

Software version | 软件版本 (magic-pdf --version)
1.0.x

Device mode | 设备模式
cuda

🌰 Minimal Reproducible Example (最小可复现问题的Demo)

fastapi部署服务后,发多次请求会报错,以下提供mineru的代码库,可以直接用mineru的fastapi服务(去掉async def pdf_parse()中的async可多线程并发)进行复现;
https://github.com/opendatalab/MinerU?tab=readme-ov-file
opendatalab/MinerU#1891

@GreatV
Copy link
Collaborator

GreatV commented Mar 11, 2025

可以试试升级一下paddlepaddle版本到3.0 rc1
Related issues:

@Luux
Copy link

Luux commented Mar 12, 2025

I have this problem also when using in a threaded environment (even when doing everything related paddleocr initialization and inference with a threadlock!) and when using it in pytest sessions.

Tried with paddlepaddle 3.0 rc1.

It works with paddlepaddle-2.6.2, but I'm running into a memory leak there.

Kinda breaks PaddleOCR for me currently :/

@mauryaland
Copy link
Contributor

Same as Luux here.

@Luux
Copy link

Luux commented Mar 12, 2025

This is the memory leak I'm talking about: #7823

@Luux
Copy link

Luux commented Mar 12, 2025

Oh and btw.: I'm using it on CPU. So the problem is also there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants