Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

导出int8的完整流程 #28

Open
XiaoJiNu opened this issue Jun 9, 2024 · 4 comments
Open

导出int8的完整流程 #28

XiaoJiNu opened this issue Jun 9, 2024 · 4 comments

Comments

@XiaoJiNu
Copy link

XiaoJiNu commented Jun 9, 2024

你好,文档中没有看到转换为int8并实现推理的完整流程,能否支持该功能

@Melody-Zhou
Copy link
Owner

你好,文档中没有看到转换为int8并实现推理的完整流程,能否支持该功能

支持,该 repo 沿用的是 tensorRT_Pro 中的 INT8 量化方案,采用的是 TRT C++ API 实现 PTQ 量化,因此你只需要在量化时指定 calibration dataset 路径即可,使用示例如下:

TRT::compile(
    mode,                       // FP32、FP16、INT8
    test_batch_size,            // max batch size
    onnx_file,                  // source 
    model_file,                 // save to
    {},
    int8process,
    "inference",
    "calibration_dataset",	// 指定校准数据集路径
    "calib.entropy.cache",	// 指定保存的校准文件名
    "Calibrator::Entropy",	// 指定校准器,目前仅支持 Entropy 和 MinMax
);

@XiaoJiNu
Copy link
Author

谢谢,现在提示这个错误,我用的tensorrt版本是tensorrt-8.6.1,是onnx-tensorrt版本不对是吗
[2024-06-10 12:27:08][info][app_yolo.cpp:133]:===================== test YoloV10 INT8 yolov10n ==================================
[2024-06-10 12:27:08][warn][trt_builder.cpp:550]:Too few images provided, 6[provided] < 16[max batch size], image copy will be performed
[2024-06-10 12:27:08][info][trt_builder.cpp:564]:Compile INT8 Onnx Model 'yolov10n.onnx'.
[2024-06-10 12:27:13][error][trt_builder.cpp:30]:NVInfer: /home/yr/yr/code/cv/object_detection/tensorRT_Pro-YOLOv8/src/tensorRT/onnx_parser/ModelImporter.cpp:736: While parsing node number 310 [GatherElements -> "/model.23/GatherElements_output_0"]:
[2024-06-10 12:27:13][error][trt_builder.cpp:30]:NVInfer: /home/yr/yr/code/cv/object_detection/tensorRT_Pro-YOLOv8/src/tensorRT/onnx_parser/ModelImporter.cpp:737: --- Begin node ---
[2024-06-10 12:27:13][error][trt_builder.cpp:30]:NVInfer: /home/yr/yr/code/cv/object_detection/tensorRT_Pro-YOLOv8/src/tensorRT/onnx_parser/ModelImporter.cpp:738: input: "/model.23/Split_3_output_0"
input: "/model.23/Tile_output_0"
output: "/model.23/GatherElements_output_0"
name: "/model.23/GatherElements"
op_type: "GatherElements"
attribute {
name: "axis"
i: 1
type: INT
}

[2024-06-10 12:27:13][error][trt_builder.cpp:30]:NVInfer: /home/yr/yr/code/cv/object_detection/tensorRT_Pro-YOLOv8/src/tensorRT/onnx_parser/ModelImporter.cpp:739: --- End node ---
[2024-06-10 12:27:13][error][trt_builder.cpp:30]:NVInfer: /home/yr/yr/code/cv/object_detection/tensorRT_Pro-YOLOv8/src/tensorRT/onnx_parser/ModelImporter.cpp:741: ERROR: /home/yr/yr/code/cv/object_detection/tensorRT_Pro-YOLOv8/src/tensorRT/onnx_parser/builtin_op_importers.cpp:1455 In function importGatherElements:
[8] Assertion failed: !isDynamic(daDims) && !isDynamic(idxDims) && "This version of TenosrRT does not support GatherElements on dynamic shapes!"
[2024-06-10 12:27:13][error][trt_builder.cpp:609]:Can not parse OnnX file: yolov10n.onnx
[2024-06-10 12:27:13][error][yolo.cpp:202]:Engine yolov10n.INT8.trtmodel load failed
[2024-06-10 12:27:13][error][app_yolo.cpp:53]:Engine is nullptr

@Melody-Zhou
Copy link
Owner

算子解析问题,提示说这个版本的 TensorRT 不支持动态 shape 的 GatherElements 算子,默认使用的 onnxparser 版本是 8.0 的,你可能需要手动替换 onnx_parser 具体可以参考:RT-DETR推理详解及部署实现

@XiaoJiNu
Copy link
Author

好的谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants