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

I'm looking for a way to limit memory usage in CPU mode #7155

Closed
Luyin opened this issue Aug 9, 2022 · 2 comments
Closed

I'm looking for a way to limit memory usage in CPU mode #7155

Luyin opened this issue Aug 9, 2022 · 2 comments

Comments

@Luyin
Copy link

Luyin commented Aug 9, 2022

请提供下述完整信息以便快速定位问题/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)
@andyjiang1116
Copy link
Collaborator

Maybe you use the multi process mode, the memory usage will increase, but it should reach a peak when all process is used.

@gavinfaimdata
Copy link

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.

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

No branches or pull requests

3 participants