RapidAI / RapidOCR

Awesome OCR multiple programing languages toolkits based on ONNXRuntime, OpenVION and PaddlePaddle.
https://rapidai.github.io/RapidOCRDocs
Apache License 2.0
2.98k stars 357 forks source link

rapidocr_paddle的cpu_math_library_num_threads设置有误 #214

Open SWHL opened 2 months ago

SWHL commented 2 months ago

你好,我实际测试下来,发现CPU上rapidocr_onnxruntime性能比rapidocr_paddle好,但是这个差异主要是默认的cpu_math_library_num_threads没有设置导致的。具体原因是:以下这个分支里的设置线程数没有跑进去,导致paddle CPU推理的默认性能很差。

cpu_nums = os.cpu_count()
infer_num_threads = config.get("cpu_math_library_num_threads", -1)
if infer_num_threads != -1 and 1 <= infer_num_threads <= cpu_nums:
     infer_opts.set_cpu_math_library_num_threads(infer_num_threads)

希望把默认的infer_num_threads这块改一下。

Originally posted by @vivienfanghuagood in https://github.com/RapidAI/RapidOCR/discussions/196#discussioncomment-10405131

SWHL commented 1 month ago

该问题查看源码,当前逻辑是:如果不显式指定infer_num_threads,则不通过inference.set_cpu_math_library_num_threads来设置,采用Config初始化的默认值。@vivienfanghuagood