ppocrv5 推理显存持续升高
🔎 Search before asking
- [x] I have searched the PaddleOCR Docs and found no similar bug report.
- [x] I have searched the PaddleOCR Issues and found no similar bug report.
- [x] I have searched the PaddleOCR Discussions and found no similar bug report.
🐛 Bug (问题描述)
使用ocr pileline进行推理,显存持续升高,跑了大概几千张图片,显存已经占用到8个G
🏃♂️ Environment (运行环境)
python 3.9.23 paddleocr 3.1.0 install pip cuda 11.8
🌰 Minimal Reproducible Example (最小可复现问题的Demo)
mport os from paddleocr import PaddleOCR
ocr = PaddleOCR( use_doc_orientation_classify=False, use_doc_unwarping=False, use_textline_orientation=False, text_detection_model_name="PP-OCRv5_server_det", text_recognition_model_name="PP-OCRv5_server_rec", rec_model_dir = "/mnt/workspace/multimodal_llm/PaddleOCR/PP-OCRv5_server_rec_infer", device = 'gpu', ) for img in img_list: # output = model.predict(img, batch_size=1) ocr.predict(input = img)
请问如果重复推理同一张图,能观察到类似的现象吗?
图片宽高多少?如果不限制图片大小的话,PP-OCRv5_server_det推理的时候显存占用很大。
图片宽高多少?如果不限制图片大小的话,PP-OCRv5_server_det推理的时候显存占用很大。
我确实没有限制图片的大小,大小都不太一样,但是我理解每一张推理完之后显存都是会释放的,所以现存占用应该是是一个波动的情况,但是我现在的显存看上去一直是在增加。
现在的情况是我推理完之后用paddle.device.cuda.empty_cache()解决了 需要手动释放一下
图片宽高多少?如果不限制图片大小的话,PP-OCRv5_server_det推理的时候显存占用很大。
我确实没有限制图片的大小,大小都不太一样,但是我理解每一张推理完之后显存都是会释放的,所以现存占用应该是是一个波动的情况,但是我现在的显存看上去一直是在增加。
现在的情况是我推理完之后用paddle.device.cuda.empty_cache()解决了 需要手动释放一下
好奇,这样会导致内存的复用率下降吗?
which version of paddleocr and paddlepaddle-gpu on your case, mycode inferecese with cpu not gpu.
这是paddle做的优化,把推理过的尺寸都存在显存里,下次再遇到相同尺寸不用重新申请空间,然而生产中这种优化是负向的。。。
这是paddle做的优化,把推理过的尺寸都存在显存里,下次再遇到相同尺寸不用重新申请空间,然而生产中这种优化是负向的。。。
合理...
finally:
gc.collect()
if paddle.device.is_compiled_with_cuda():
paddle.device.cuda.empty_cache()
logger.debug("最终清空 CUDA 缓存。")
加这个可以
finally: gc.collect() if paddle.device.is_compiled_with_cuda(): paddle.device.cuda.empty_cache() logger.debug("最终清空 CUDA 缓存。")加这个可以
请教一下 我在执行paddle.device.cuda.empty_cache()时报错:<module 'paddle.device' from '/root/miniconda3/envs/ocr-gpu-v3.1/lib/python3.11/site-packages/paddle/device/init.py'> (External) CUDA error(2), out of memory. [Hint: 'cudaErrorMemoryAllocation'. The API call failed because it was unable to allocate enough memory to perform the requested operation. ] (at ../paddle/phi/backends/gpu/cuda/cuda_info.cc:206)-------------但是我显卡上可用显存还有20G
请问如果重复推理同一张图,能观察到类似的现象吗?
也会出现,我这边用的固定图片尺寸,显存占用一直涨
同样是3.1.0,用了很长时间了,经常要重启,服务化部署的pipeline,刚启动的时候占用2~5个g,然后持续升高,占用20几g,然后调用就没反应,只能重启api