# Loss data when build engine from onnx

**URL:** <https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603>\
**Category:** DeepStream SDK\
**Tags:** nvbugs\
**Created:** [October 21, 2020, 10:10am UTC](https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603 "2020-10-21T10:10:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ducbx2020](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ducbx2020](https://forums.developer.nvidia.com/u/ducbx2020)\
**Post date:** [October 21, 2020, 10:10am UTC](https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603/1 "2020-10-21T10:10:42Z")

</div>

## hi dear, I want to run crnn model on deepstream but I have a problem when convert my model to tensorrt engine Environment: ubuntu 18.04, cuda 10.2, deepstream 5.0, tensorrt 7.1.3.4 I converted model file to onnx from pytorch, and then I use onnxruntime to test this weight → result: OK output: 3-dims But when I run deepstream-app to build engine file and run this project, my output was loss to 2-dims

- onnx test result  
image.shape: torch.Size([1, 3, 32, 128])  
preds.shape: torch.Size([14, 1, 131])
- deepstream-app  
0 INPUT kFLOAT input0 3x32x128  
1 OUTPUT kFLOAT output0 1x131

please help me check it  
many thanks

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [October 22, 2020, 2:42am UTC](https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603/3 "2020-10-22T02:42:32Z")

</div>

Hi,

Usually, we use the first dimension for the batch size.  
Do you mean the input is one image with size = 3x32x128?  
And the corresponding output is [**1,** 14, 1, 131]?

Or an image with size = 1x3x32x128? (4-dimesion input)

Thanks.

---

<div class="post-metadata">

**Author:** ![ducbx2020](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ducbx2020](https://forums.developer.nvidia.com/u/ducbx2020)\
**Post date:** [October 22, 2020, 6:44am UTC](https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603/4 "2020-10-22T06:44:02Z")

</div>

hi, thank for your responding.

input image have size = (3x32x128) → 3 dims, 1 is batch size  
both of 2 cases have the same input …

correct output for an image should be (14, 1, 131) but when I run on deepstream-app, output was (1,131)

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [October 23, 2020, 3:41am UTC](https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603/5 "2020-10-23T03:41:08Z")

</div>

Hi,

Not sure if we understand your problem correctly.  
If the batch size is 1, the output should be [**1** , 14, 1, 131]?

We try to confirm this since some models will do the cross-batch operation, and it is not supported by Deepstream right now.

Thanks.

---

<div class="post-metadata">

**Author:** ![ducbx2020](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ducbx2020](https://forums.developer.nvidia.com/u/ducbx2020)\
**Post date:** [October 23, 2020, 4:40am UTC](https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603/6 "2020-10-23T04:40:29Z")

</div>

hi,  
"If the batch size is 1, the output should be [**1** , 14, 1, 131]? " → right  
==\>  
input: (1x3x32x128)  
output: (1, 14, 1, 131)

sorry because my question is not clearly

thanks

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [October 27, 2020, 5:12am UTC](https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603/7 "2020-10-27T05:12:27Z")

</div>

Hi,

It’s okay.

May I know what kind of input format do you use? Is it NCHW or NHWC?  
It’s possible that your model is using NHWC, but TensorRT treats it as NCHW.

If your model is already using NCHW, please share the ONNX model with us for checking?  
Thanks.

---

<div class="post-metadata">

**Author:** ![ducbx2020](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ducbx2020](https://forums.developer.nvidia.com/u/ducbx2020)\
**Post date:** [October 28, 2020, 4:44am UTC](https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603/8 "2020-10-28T04:44:05Z")

</div>

I would like to send you my onnx file  
[https://drive.google.com/file/d/1Ufit2sEpxD2eeFYGbHvqqzKhxMnzwM4T/view?usp=sharing](https://drive.google.com/file/d/1Ufit2sEpxD2eeFYGbHvqqzKhxMnzwM4T/view?usp=sharing)

please help me check it  
thanks

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [October 29, 2020, 5:05am UTC](https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603/9 "2020-10-29T05:05:19Z")

</div>

Hi,

Thanks for your sharing.  
It seems that you are meeting the same issue of [Miss ouput when convert Onnx to TensorRT](https://forums.developer.nvidia.com/t/miss-ouput-when-convert-onnx-to-tensorrt/157681).

Our internal team is checking on this.  
We will update more information here once got any feedback.

Thanks.

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [November 6, 2020, 3:55am UTC](https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603/11 "2020-11-06T03:55:33Z")

</div>

Hi,

We found [Miss ouput when convert Onnx to TensorRT](https://forums.developer.nvidia.com/t/miss-ouput-when-convert-onnx-to-tensorrt/157681) is a custom issue rather than a bug.  
Could you check the latest comment **[here](https://forums.developer.nvidia.com/t/miss-ouput-when-convert-onnx-to-tensorrt/157681/10)** also.

Thanks.

---

<div class="post-metadata">

**Author:** ![TomNVIDIA](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tomnvidia/32/14181_2.png) [@TomNVIDIA](https://forums.developer.nvidia.com/u/TomNVIDIA)\
**Post date:** [October 12, 2021, 4:16pm UTC](https://forums.developer.nvidia.com/t/loss-data-when-build-engine-from-onnx/157603/13 "2021-10-12T16:16:04Z")

</div>

Closed on October 12, 2021, 4:16pm UTC


