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)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

表格结构识别模型推理时使用GPU比不使用GPU更耗时

sunqin14 opened this issue · comments

  • 系统环境/System Environment:
    系统:centos

  • 版本号/Version:
    python:3.8.13
    Paddle: paddlepaddle-gpu== 2.2.1.post112
    PaddleOCR: release/2.5

  • 运行指令/Command Code:
    cd PaddleOCR/ppstructure
    python3 table/predict_structure.py --table_model_dir=inference/en_ppocr_mobile_v2.0_table_structure_infer --image_dir=./docs/table/table.jpg --table_char_dict_path=../ppocr/utils/dict/table_structure_dict.txt --output ./output/table --use_gpu=False

    其中 --use_gpu=False 根据使用或不使用GPU改成 True/False

  • 问题:
    使用GPU进行推理时更耗时

    更耗时部分主要包含两个模块:

    1. self.input_tensor.copy_from_cpu(img)
    2. self.predictor.run()

单独测试一下self.predictor.run()的耗时看看,可能是拷贝数据花费了太多时间

开启GPU
(pp221) [root@gpu-8 ppstructure]# python3 table/predict_structure.py --table_model_dir=./inference/en_ppocr_mobile_v2.0_table_structure_infer --image_dir=./docs/table/table.jpg --table_char_dict_path=../ppocr/utils/dict/table_structure_dict.txt --output ./output/table --use_gpu=True
copy data time: 1.947709083557129
predict time: 1.5352413654327393

关闭GPU
(pp221) [root@gpu-8 ppstructure]#python3 table/predict_structure.py --table_model_dir=./inference/en_ppocr_mobile_v2.0_table_structure_infer --image_dir=./docs/table/table.jpg --table_char_dict_path=../ppocr/utils/dict/table_structure_dict.txt --output ./output/table --use_gpu=False
copy data time: 1.8496778011322021
predict time: 1.539719581604004

开启GPU拷贝数据比关闭GPU慢一点点,而self.predictor.run()几乎无变化。。为什么开启GPU后 self.predictor.run()模块不会变快呢?

跑了几次呢 一般跑20次取平均值

我遇到了同样的问题,不过我是ch_ppstructure_mobile_v2.0_SLANet推理模型转onnx部署在triton上的,GPU推理2.33infer/sec,CPU推理2.38infer/sec。