# Can't get INT8 precision to work

**URL:** <https://forums.developer.nvidia.com/t/cant-get-int8-precision-to-work/228596>\
**Category:** Jetson Xavier NX\
**Tags:** ngc, containers, python, tensorrt\
**Created:** [September 21, 2022, 8:56am UTC](https://forums.developer.nvidia.com/t/cant-get-int8-precision-to-work/228596 "2022-09-21T08:56:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alessandrosantella11](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@alessandrosantella11](https://forums.developer.nvidia.com/u/alessandrosantella11)\
**Post date:** [September 21, 2022, 8:56am UTC](https://forums.developer.nvidia.com/t/cant-get-int8-precision-to-work/228596/1 "2022-09-21T08:56:35Z")

</div>

Hi, I’m working on a NVIDIA Jetson Xavier NX to convert ONNX models using TensorRT in Python and I’m having an issue with the conversion to INT8 precision.

By simply using the --int8 flag of the trtexec command (without the --calib flag), I am able to get the converted model but its predictions are wrong (e.g. for a gender recognition problem from images, the model predicts one of the two genders with 0.49 probability and the other with 0.51) despite the fact that the original model and the model with FP16 precision had very good performance.

I also tried to follow one of the samples on github (TensorRT/samples/python/int8\_caffe\_mnist/) thanks to which I was able to get a calibration cache for my models, but even these do not seem to be correct. In fact, the produced files have strange hexadecimal values (very close to infinity when converted to float32) and when I try to convert the model using the file with the --calib flag of trtexec I get a model that predicts NaN instead of the necessary probability values.

The TensorRT version is 8.0.1 and the models were converted from TensorFlow to ONNX using opset 13.

I hope I have been clear in my explanation of the problem and that I have not created the topic in the wrong place.

Thanks.

---

<div class="post-metadata">

**Author:** ![NVES](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nves/32/14043_2.png) [@NVES](https://forums.developer.nvidia.com/u/NVES)\
**Post date:** [September 21, 2022, 9:37am UTC](https://forums.developer.nvidia.com/t/cant-get-int8-precision-to-work/228596/2 "2022-09-21T09:37:50Z")

</div>

Hi, Please refer to the below links to perform inference in INT8

> **[TensorRT/samples/sampleINT8 at master · NVIDIA/TensorRT](https://github.com/NVIDIA/TensorRT/tree/master/samples/sampleINT8)**
>
> NVIDIA® TensorRT™ is an SDK for high-performance deep learning inference on NVIDIA GPUs. This repository contains the open source components of TensorRT. - NVIDIA/TensorRT

> **[NVIDIA On-Demand](https://www.nvidia.com/en-us/on-demand/)**
>
> A searchable database of content from GTCs and various other events.

Thanks!

---

<div class="post-metadata">

**Author:** ![alessandrosantella11](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@alessandrosantella11](https://forums.developer.nvidia.com/u/alessandrosantella11)\
**Post date:** [September 21, 2022, 12:30pm UTC](https://forums.developer.nvidia.com/t/cant-get-int8-precision-to-work/228596/5 "2022-09-21T12:30:06Z")

</div>

Hi, I’ve already tried following the links you gave me (In fact, I looked everywhere on the internet for some help) but the situation is still the same. Maybe there is some problem with the TensorRT version?

Thanks.

---

<div class="post-metadata">

**Author:** ![spolisetty](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/spolisetty/32/14047_2.png) [@spolisetty](https://forums.developer.nvidia.com/u/spolisetty)\
**Post date:** [September 23, 2022, 11:32am UTC](https://forums.developer.nvidia.com/t/cant-get-int8-precision-to-work/228596/6 "2022-09-23T11:32:21Z")

</div>

Hi,

We are moving this post to the Jetson Xavier NX forum to get better help.  
Also, we recommend you to please try on the latest TensorRT version and let us know if you still face this issue.

You can try the TensorRT NGC container.

> **[TensorRT | NVIDIA NGC](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/tensorrt)**
>
> NVIDIA TensorRT is a C++ library that facilitates high-performance inference on NVIDIA graphics processing units (GPUs). TensorRT takes a trained network and produces a highly optimized runtime engine that performs inference for that network.

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [October 7, 2022, 11:33am UTC](https://forums.developer.nvidia.com/t/cant-get-int8-precision-to-work/228596/7 "2022-10-07T11:33:03Z")

</div>

Closed on October 7, 2022, 11:33am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
