-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 #1891
Comments
你是不是指定了flask用多进程来跑?需要在 if name == "main"那里加这一句,不然子进程cuda初始化会失败 |
没有用多进程; |
paddle框架不支持多线程,不可并发,目前并发需求只能通过多进程来解决 |
但是多进行每次都会重新加载模型,会很费时,而且多进程每个进程都会加载模型,也会很费显存; |
要么空间换时间,要么时间换空间,要么换掉paddle |
多谢 |
I have the same problem with fastapi, could I ask what is the way to fix it? I don't really get it with the translation from google. |
Description of the bug | 错误描述
2025-03-10 19:35:58 - ERROR - OCRApiDeploy2.py:upload_ocr_result:217 - Traceback (most recent call last):
File "/workspace/JuneLi/bbtv/cube-ocr/WORKFLOW/OTHER/OCR/v0/OCRApiDeploy2.py", line 161, in upload_ocr_result
result = op(
File "/workspace/JuneLi/bbtv/cube-ocr/WORKFLOW/OTHER/OCR/v0/OCRModelDeploy.py", line 356, in call
sd_hypertxt = self.get_result(file_path, force_cv=force_cv, lang=lang)
File "/workspace/JuneLi/bbtv/cube-ocr/WORKFLOW/OTHER/OCR/v0/OCRModelDeploy.py", line 321, in get_result
infer_result = ds.apply(doc_analyze, ocr=True, lang=ds._lang)
File "/root/.cache/pypoetry/virtualenvs/cube-ocr-CKM964-4-py3.10/lib/python3.10/site-packages/magic_pdf/data/dataset.py", line 212, in apply
return proc(self, *args, **kwargs)
File "/root/.cache/pypoetry/virtualenvs/cube-ocr-CKM964-4-py3.10/lib/python3.10/site-packages/magic_pdf/model/doc_analyze_by_custom_model.py", line 197, in doc_analyze
analyze_result = batch_model(images)
File "/root/.cache/pypoetry/virtualenvs/cube-ocr-CKM964-4-py3.10/lib/python3.10/site-packages/magic_pdf/model/batch_analyze.py", line 134, in call
ocr_res = self.model.ocr_model.ocr(
File "/root/.cache/pypoetry/virtualenvs/cube-ocr-CKM964-4-py3.10/lib/python3.10/site-packages/magic_pdf/model/sub_modules/ocr/paddleocr/ppocr_273_mod.py", line 85, in ocr
dt_boxes, rec_res, _ = self.call(img, cls, mfd_res=mfd_res)
File "/root/.cache/pypoetry/virtualenvs/cube-ocr-CKM964-4-py3.10/lib/python3.10/site-packages/magic_pdf/model/sub_modules/ocr/paddleocr/ppocr_273_mod.py", line 148, in call
dt_boxes, elapse = self.text_detector(img)
File "/root/.cache/pypoetry/virtualenvs/cube-ocr-CKM964-4-py3.10/lib/python3.10/site-packages/paddleocr/tools/infer/predict_det.py", line 396, in call
dt_boxes, elapse = self.predict(img)
File "/root/.cache/pypoetry/virtualenvs/cube-ocr-CKM964-4-py3.10/lib/python3.10/site-packages/paddleocr/tools/infer/predict_det.py", line 255, in predict
self.predictor.run()
RuntimeError: could not execute a primitive
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
The text was updated successfully, but these errors were encountered: