1. 报错信息

今天在yolov5模型转换为TensorRT模型时报错:

Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64

详细报错信息如下:

----------------------------------------------------------------
Input filename:   ../models/yolov5s.onnx
ONNX IR version:  0.0.6
Opset version:    13
Producer name:    pytorch
Producer version: 1.9
Domain:           
Model version:    0
Doc string:       
----------------------------------------------------------------
[2023-03-08 07:33:55 WARNING] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[2023-03-08 07:33:55 WARNING] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[2023-03-08 07:33:55 WARNING] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.

 

2. 原因分析

根据提示,我们可以发现原因:

因为我们的onnx模型参数类型是INT64, 然后TensorRT是不支持 INT64的。这就需要我们先把ONNX模型的精度降到 INT32,然后再进行转换为 TensorRT模型。

3. 解决办法

具体操作如下:

先对onnx模型进行onnxsim 简化:

python -m onnxsim yolov5s.onnx yolov5s_sim.onnx
./trtexec --onnx=yolov5s_sim.onnx --saveEngine=yolov5s.engine

这样就解决了

GitHub 加速计划 / yo / yolov5
49.42 K
16.03 K
下载
yolov5 - Ultralytics YOLOv8的前身,是一个用于目标检测、图像分割和图像分类任务的先进模型。
最近提交(Master分支:2 个月前 )
79b7336f * Update Integrations table Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> * Update README.md Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> * Update README.zh-CN.md Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> --------- Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> 28 天前
94a62456 * fix: quad training * fix: quad training in segmentation 30 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐