PaddleOCR
PaddleOCR copied to clipboard
I'm looking for a way to limit memory usage in CPU mode
请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem
- 系统环境/System Environment: Intel CPU Ubuntu 20.04
- 版本号/Version:Paddle: PaddleOCR: 问题相关组件/Related components: paddleOCR 2.5.0.3
First of all, thank you very much for developing such good software.
I am running PaddleOCR in CPU mode, and whenever I perform inference, there is a problem that the memory usage keeps increasing. Is there any way to limit memory usage?
Paddle OCR Initialization Code
paddle_ch = PaddleOCR(
show_log=False,
lang="ch",
cpu_threads=1,
det_db_thresh=0.1,
det_db_box_thresh=0.1,
use_mp=True,
enable_mkldnn=True,
total_process_num=os.cpu_count() * 2 - 1,
use_angle_cls=True,
cls_model_dir="whl/cls/ch_ppocr_mobile_v2.0_cls_infer",
det_model_dir="whl/det/ch/ch_PP-OCRv3_det_infer",
rec_model_dir="whl/rec/ch/ch_PP-OCRv3_rec_infer"
)
Memory Profiler Result of PaddleOCR
ocr_1 | Line # Mem usage Increment Occurrences Line Contents
ocr_1 | =============================================================
ocr_1 | 108 # 2. OCR
ocr_1 | 109 556.8 MiB 0.0 MiB 1 try:
ocr_1 | 110 556.8 MiB 0.0 MiB 1 if model.language in self.paddle_ocr:
ocr_1 | 111 938.6 MiB 381.8 MiB 1 paddle_ocr_result = self.paddle_ocr[model.language].ocr(crop_img, cls=False)
Maybe you use the multi process mode, the memory usage will increase, but it should reach a peak when all process is used.
I'm looking for a way to limit memory usage as well, on GPU.
Running "python3 /tools/infer/predict_system.py" takes about 4.4GB of RAM (on Jetson). I'm using SVTR tiny for rec and mobilenetv3 DB for det.