Skip to content

Out of memory error on GPU  #8783

@danbao12138

Description

@danbao12138

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

  • 系统环境/System Environment:ubuntu18

  • 版本号/Version:Paddle:2.2.1.post112 PaddleOCR:2.6.1.2 问题相关组件/Related components:ppstructure
    cuda11.3 +cudnn8.4 +paddlepaddle-gpu==2.2.1.post112 +paddleocr ==2.6.1.2 +python3.8

  • 运行指令/Command Code:
    python执行以下脚本:
    import cv2
    from paddleocr import PPStructure,save_structure_res,PaddleOCR
    table_engine = PPStructure(layout=False, show_log=True)
    img = cv2.imread("./5_0.jpg") #OOM
    result = table_engine(img)
    print(result)

  • 完整报错/Complete Error Message:
    /home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddle/vision/transforms/functional_pil.py:36: DeprecationWarning: NEAREST is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.NEAREST or Dither.NONE instead.
    'nearest': Image.NEAREST,
    /home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddle/vision/transforms/functional_pil.py:37: DeprecationWarning: BILINEAR is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BILINEAR instead.
    'bilinear': Image.BILINEAR,
    /home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddle/vision/transforms/functional_pil.py:38: DeprecationWarning: BICUBIC is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BICUBIC instead.
    'bicubic': Image.BICUBIC,
    /home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddle/vision/transforms/functional_pil.py:39: DeprecationWarning: BOX is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BOX instead.
    'box': Image.BOX,
    /home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddle/vision/transforms/functional_pil.py:40: DeprecationWarning: LANCZOS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.
    'lanczos': Image.LANCZOS,
    /home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddle/vision/transforms/functional_pil.py:41: DeprecationWarning: HAMMING is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.HAMMING instead.
    'hamming': Image.HAMMING
    [2023/01/04 11:26:44] ppocr DEBUG: Namespace(alpha=1.0, benchmark=False, beta=1.0, cls_batch_num=6, cls_image_shape='3, 48, 192', cls_model_dir=None, cls_thresh=0.9, cpu_threads=10, crop_res_save_dir='./output', det=True, det_algorithm='DB', det_box_type='quad', det_db_box_thresh=0.6, det_db_score_mode='fast', det_db_thresh=0.3, det_db_unclip_ratio=1.5, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_east_score_thresh=0.8, det_limit_side_len=960, det_limit_type='max', det_model_dir='/home/ubuntu/.paddleocr/whl/det/ch/ch_PP-OCRv3_det_infer', det_pse_box_thresh=0.85, det_pse_min_area=16, det_pse_scale=1, det_pse_thresh=0, det_sast_nms_thresh=0.2, det_sast_score_thresh=0.5, draw_img_save_dir='./inference_results', drop_score=0.5, e2e_algorithm='PGNet', e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_limit_side_len=768, e2e_limit_type='max', e2e_model_dir=None, e2e_pgnet_mode='fast', e2e_pgnet_score_thresh=0.5, e2e_pgnet_valid_set='totaltext', enable_mkldnn=False, fourier_degree=5, gpu_mem=500, help='==SUPPRESS==', image_dir=None, image_orientation=False, ir_optim=True, kie_algorithm='LayoutXLM', label_list=['0', '180'], lang='ch', layout=False, layout_dict_path='/home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddleocr/ppocr/utils/dict/layout_dict/layout_cdla_dict.txt', layout_model_dir='/home/ubuntu/.paddleocr/whl/layout/picodet_lcnet_x1_0_fgd_layout_cdla_infer', layout_nms_threshold=0.5, layout_score_threshold=0.5, max_batch_size=10, max_text_length=25, merge_no_span_structure=True, min_subgraph_size=15, mode='structure', ocr=True, ocr_order_method=None, ocr_version='PP-OCRv3', output='./output', page_num=0, precision='fp32', process_id=0, re_model_dir=None, rec=True, rec_algorithm='SVTR_LCNet', rec_batch_num=6, rec_char_dict_path='/home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddleocr/ppocr/utils/ppocr_keys_v1.txt', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_model_dir='/home/ubuntu/.paddleocr/whl/rec/ch/ch_PP-OCRv3_rec_infer', recovery=False, save_crop_res=False, save_log_path='./log_output/', scales=[8, 16, 32], ser_dict_path='../train_data/XFUND/class_list_xfun.txt', ser_model_dir=None, show_log=True, sr_batch_num=1, sr_image_shape='3, 32, 128', sr_model_dir=None, structure_version='PP-StructureV2', table=True, table_algorithm='TableAttn', table_char_dict_path='/home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddleocr/ppocr/utils/dict/table_structure_dict_ch.txt', table_max_len=488, table_model_dir='/home/ubuntu/.paddleocr/whl/table/ch_ppstructure_mobile_v2.0_SLANet_infer', total_process_num=1, type='ocr', use_angle_cls=False, use_dilation=False, use_gpu=True, use_mp=False, use_npu=False, use_onnx=False, use_pdf2docx_api=False, use_pdserving=False, use_space_char=True, use_tensorrt=False, use_visual_backbone=True, use_xpu=False, vis_font_path='./doc/fonts/simfang.ttf', warmup=False)
    [2023/01/04 11:26:44] ppocr WARNING: When args.layout is false, args.ocr is automatically set to false
    [2023/01/04 11:26:47] ppocr DEBUG: dt_boxes num : 25, elapse : 0.027103662490844727
    Traceback (most recent call last):
    File "test_paddle.py", line 6, in
    result = table_engine(img)
    File "/home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddleocr/paddleocr.py", line 645, in call
    res, _ = super().call(
    File "/home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddleocr/ppstructure/predict_system.py", line 129, in call
    res, table_time_dict = self.table_system(
    File "/home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddleocr/ppstructure/table/predict_table.py", line 90, in call
    dt_boxes, rec_res, det_elapse, rec_elapse = self._ocr(
    File "/home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddleocr/ppstructure/table/predict_table.py", line 137, in _ocr
    rec_res, rec_elapse = self.text_recognizer(img_crop_list)
    File "/home/ubuntu/project/lib20221230/env38/lib/python3.8/site-packages/paddleocr/tools/infer/predict_rec.py", line 608, in call
    self.predictor.run()
    RuntimeError: ResourceExhaustedError:

Out of memory error on GPU 0. Cannot allocate 8.254151GB memory on GPU 0, 5.149536GB memory has been allocated and available memory is only 6.752441GB.

Please check whether there is any other process using GPU 0.

  1. If yes, please stop them, or start PaddlePaddle on another GPU.
  2. If no, please decrease the batch size of your model.

(at /paddle/paddle/fluid/memory/allocation/cuda_allocator.cc:79)

大部分图片识别时只需要1G多显存就可以正常识别,但是个别图片就会要求分配8.254151GB的显存导致OOM

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions