GPU 推理耗时太长
#118
|
作者您好,我在a100gpu上,按照您给出的代码推理和您同一张60kb的图片,但是发现推理时间和使用cpu差不多,都是4.多秒,并且观察到gpu上是有相应的计算和显存波动的,请问这是为什么 from rapidocr import RapidOCR
import time
from rapid_table import ModelType, RapidTable, RapidTableInput
ocr_engine = RapidOCR()
input_args = RapidTableInput(
model_type=ModelType.UNITABLE,
engine_cfg={"use_cuda": True, "cuda_ep_cfg.gpu_id": 1},
)
table_engine = RapidTable(input_args)
img_path = "/home/admin001/YY/RapidTable-main/demo_train/table.jpg"
start_time = time.time()
ori_ocr_res = ocr_engine(img_path)
ocr_results = [ori_ocr_res.boxes, ori_ocr_res.txts, ori_ocr_res.scores]
print(f"all time{start_time - time.time()}")
results = table_engine(img_path, ocr_results=ocr_results)
results.vis(save_dir="outputs", save_name="vis10") |
Answered by
SWHL
Jul 14, 2025
Replies: 1 comment 1 reply
|
首先,仅测一张图,并不能明确看出时间差异,因为模型需要预热。建议多测几张,避开第一张的时间,计算平均耗时。 |
1 reply
Answer selected by
MMVAT
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
首先,仅测一张图,并不能明确看出时间差异,因为模型需要预热。建议多测几张,避开第一张的时间,计算平均耗时。