NVIDIA / NVIDIA/TensorRT

An inference error occurred after converting ONNX to tensorrt

Open
#4,460 1 comment 0 reactions 1 assignee View on GitHub

@nzmora-nvidia is already working on this.

Since Jun 3, 2025.

Module:Accuracy triaged
Dominant language
C++
Stars
13.4k
Forks
2.4k
Avg merge
5d 3h
Merged PRs (30d)
2

Description

When I was using UNet for image segmentation, after converting the pytorch format model to the tensorrt format, there would be a large error in the reasoning, as follows:

Image

But the label image is like the following:

Image

However, when I perform reasoning using the.pth format or the.onnx format, I can obtain a normal result (the prediction result is similar to a label).

When converting the onnx model to tensorrt format, I tried various methods, using code and tools (trtexec and Polygraphy), and employed a wide range of precisions (FP32/FP16/int8+ calibration). All will get wrong results.

And when using Polygraphy to analyze the layers of the onnx model and the engine model, the analysis results all passed the [instruction: polygraphy run UNet.onnx --load -- outputs UNet_onnx_out.json UNet_engine_out.json --onnxrt --trt --fail-fast】.

However, I saved the output of onnx inference and tensorrt inference as.npy files and compared the two files. Indeed, there are significant differences between them. The errors at many positions exceed 0.9.

I sincerely hope to receive everyone's help!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.