PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
44.55k stars 7.85k forks source link

set `use_gpu=True` but the debugging log shows `use_gpu=False` #11935

Closed annahung31 closed 7 months ago

annahung31 commented 7 months ago

Hi I set use_gpu=True but the debugging log shows use_gpu=False.... What should I do?

The following is my env setting:

paddlepaddle-gpu 2.5.0
paddlepaddle 2.6.1
paddleocr 2.7.2
cuda version  10.8

my code:

    ocr = PaddleOCR(use_angle_cls=True, 
                    use_gpu=True,
                    lang="ch")

debugging message:

[2024/04/12 03:27:49] ppocr DEBUG: Namespace(alpha=1.0, alphacolor=(255, 255, 255), benchmark=False, beta=1.0, binarize=False, cls_batch_num=6, cls_image_shape='3, 48, 192', cls_model_dir='/root/.paddleocr/whl/cls/ch/ch_ppocr_mobile_v2.0_cls_infer', 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='/root/.paddleocr/whl/det/en/ch_PP-OCRv4_det_server_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_id=0, gpu_mem=500, help='==SUPPRESS==', image_dir=None, image_orientation=False, invert=False, ir_optim=True, kie_algorithm='LayoutXLM', label_list=['0', '180'], lang='ch', layout=True, layout_dict_path=None, layout_model_dir=None, 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-OCRv4', 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='/usr/local/lib/python3.8/dist-packages/paddleocr/ppocr/utils/ppocr_keys_v1.txt', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_model_dir='/root/.paddleocr/whl/rec/en/ch_PP-OCRv4_rec_server_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=None, table_max_len=488, table_model_dir=None, total_process_num=1, type='ocr', use_angle_cls=True, use_dilation=False, use_gpu=False, 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) [2024/04/12 03:27:54] ppocr DEBUG: dt_boxes num : 49, elapsed : 3.9109363555908203 [2024/04/12 03:27:55] ppocr DEBUG: cls num : 49, elapsed : 0.08451628684997559 [2024/04/12 03:28:05] ppocr DEBUG: rec_res num : 49, elapsed : 10.290374040603638

inference time: 15.56s

UserWangZz commented 7 months ago

Check if the log output is before updating useugpu=true. During the training process, it is possible to check if the GPU memory has changed to determine whether the GPU has been used.

annahung31 commented 7 months ago

Thanks for replying. I use the check_gpu function to test directly and still found the result is False. It turns out that I didn't set up the paddlepaddle-gpu correctly so it cannot access to my GPU.

The reason is that the Cuda version is not aligned with my environment.

So instead of installing paddlepaddle-gpu via pip, I turned to use the docker image with the correct cuda version, and then it worked.

omumarvaishya005 commented 6 months ago

hii guys im also having the same issue even i have fixed use_gpu as true but when im debugging its saying use_gpu=false here is the debug message please help me i need a urgent support ppocr DEBUG: Namespace(help='==SUPPRESS==', use_gpu=False, use_xpu=False, use_npu=False, ir_optim=True, use_tensorrt=False, min_subgraph_size=15, precision='fp32', gpu_mem=500, image_dir=None, page_num=0, det_algorithm='DB', det_model_dir='/var/www/ocr/models/det/v2/inference/', det_limit_side_len=2000, det_limit_type='max', det_box_type='quad', det_db_thresh=0.3, det_db_box_thresh=0.6, det_db_unclip_ratio=1.5, max_batch_size=10, use_dilation=False, det_db_score_mode='slow', det_east_score_thresh=0.8, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_sast_score_thresh=0.5, det_sast_nms_thresh=0.2, det_pse_thresh=0, det_pse_box_thresh=0.85, det_pse_min_area=16, det_pse_scale=1, scales=[8, 16, 32], alpha=1.0, beta=1.0, fourier_degree=5, rec_algorithm='SVTR_LCNet', rec_model_dir='/var/www/ocr/models/rec/v3/inference/', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_batch_num=6, max_text_length=25, rec_char_dict_path='/var/www/ocr/models/rec/v3/inference/dict.txt', use_space_char=True, vis_font_path='./doc/fonts/simfang.ttf', drop_score=0.5, e2e_algorithm='PGNet', e2e_model_dir=None, e2e_limit_side_len=768, e2e_limit_type='max', e2e_pgnet_score_thresh=0.5, e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_pgnet_valid_set='totaltext', e2e_pgnet_mode='fast', use_angle_cls=False, cls_model_dir='/home/astc/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer', cls_image_shape='3, 48, 192', label_list=['0', '180'], cls_batch_num=6, cls_thresh=0.9, enable_mkldnn=False, cpu_threads=10, use_pdserving=False, warmup=False, sr_model_dir=None, sr_image_shape='3, 32, 128', sr_batch_num=1, draw_img_save_dir='./inference_results', save_crop_res=False, crop_res_save_dir='./output', use_mp=False, total_process_num=1, process_id=0, benchmark=False, save_log_path='./log_output/', show_log=True, use_onnx=False, output='./output', table_max_len=488, table_algorithm='TableAttn', table_model_dir=None, merge_no_span_structure=True, table_char_dict_path=None, layout_model_dir=None, layout_dict_path=None, layout_score_threshold=0.5, layout_nms_threshold=0.5, kie_algorithm='LayoutXLM', ser_model_dir=None, re_model_dir=None, use_visual_backbone=True, ser_dict_path='../train_data/XFUND/class_list_xfun.txt', ocr_order_method=None, mode='structure', imag

UserWangZz commented 6 months ago

hii guys im also having the same issue even i have fixed use_gpu as true but when im debugging its saying use_gpu=false here is the debug message please help me i need a urgent support

This may be a bug. You can track use_gpu to see if the parameters passed in are normal, update the default configuration, and make sure the paddle version is paddlepaddle-gpu.

omumarvaishya005 commented 6 months ago

thanks for replying can we connect to solve the issue as im in urgent need for this , it would be very helpful for me

UserWangZz commented 6 months ago

Check whether the gpu memory of the model inference process changes after setting use_gpu=True, because this may be just a small problem with the logger.

omumarvaishya005 commented 6 months ago

yes i checked it earlier when im trying to run inference it is more using gpu anymore even in log file use_gpu ismarked as false please help me regarding this

UserWangZz commented 6 months ago

When executing inference, is there any obvious change in the GPU memory?

omumarvaishya005 commented 6 months ago

no there is no significant chnage in gpu usages its only using cpu

omumarvaishya005 commented 6 months ago

hii @UserWangZz can we connect over a quick call to solve the issue??

UserWangZz commented 6 months ago

hii @UserWangZz can we connect over a quick call to solve the issue?? Of course

omumarvaishya005 commented 6 months ago

okay can we do it now?? https://meet.google.com/tse-uxbw-hvx this is link here you can join

UserWangZz commented 6 months ago

okay can we do it now?? https://meet.google.com/tse-uxbw-hvx this is link here you can join

sorry, i miss this message

omumarvaishya005 commented 6 months ago

so please give me time when you can join it and make sure it is arabic time zone since im in saudi arabia thanks for being kind and help full

UserWangZz commented 6 months ago

so please give me time when you can join it and make sure it is arabic time zone since im in saudi arabia thanks for being kind and help full

sorry, can you provide your code for me? and your environment about paddlepaddle and Paddleocr etc. I will try to reproduce your problem

omumarvaishya005 commented 6 months ago

if you can join then we can solve the issue very quickly other wise we both will be wasting our time

omumarvaishya005 commented 6 months ago

requirements.txt this is the requirment file that im using

omumarvaishya005 commented 6 months ago

since its a big project so sharing every thing will be not be easy

omumarvaishya005 commented 6 months ago

@UserWangZz i think i don't have paddle-gpu module with my requirement file that's why this issue is coming

omumarvaishya005 commented 6 months ago

Yes yes that's was the issue thank you so much for your support 🙏 i appreciate you kind help