TensorRT icon indicating copy to clipboard operation
TensorRT copied to clipboard

Assertion failed when use int8 calibration for common onnx model.

Open chenbohua3 opened this issue 6 years ago • 4 comments

Description

Say we have an onnx model defined as follows:

class MyModel(torch.nn.Module):
    def forward(self, x):
        x = x + 1
        return x

model = MyModel().eval()
dummy = torch.randn(1, 2, 4, 4)
torch.save([dummy], 'dummy.pt')
torch.onnx.export(model, (dummy,), 'model.onnx')

And I use dummy.npy (transformed from dummy.pt) and model.onnx to build an INT8 engine, internal error will happen:

[TensorRT] INFO: Detected 1 inputs and 1 output network tensors.
[TensorRT] WARNING: Current optimization profile is: 0. Please ensure there are no enqueued operations pending in this context prior to switching profiles
[TensorRT] INFO: Starting Calibration with batch size 1.
[TensorRT] WARNING: Explicit batch network detected and batch size specified, use execute without batch size instead.
[TensorRT] INTERNAL ERROR: Assertion failed: d.nbDims >= 1
../rtSafe/safeHelpers.cpp:419
Aborting...

But if I change the model to :

class MyModel(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = torch.nn.Conv2d(2, 3, 1, 1)
    def forward(self, x):
        x = self.conv1(x)
        return x

Everything goes will. So is this problem a known issue for trt? or is it fixed in a newer trt version?

Environment

TensorRT Version: 7.0.0.11 GPU Type: T4 Nvidia Driver Version: 418.67 CUDA Version: 10.0 CUDNN Version: 7.6.5 Operating System + Version: centos Python Version (if applicable): 3.7.7 PyTorch Version (if applicable): 1.6.0a0+9bfb91b

chenbohua3 avatar Nov 01 '20 14:11 chenbohua3

Hello @chenbohua3 , thanks for reporting this is fixed in 7.2, could you upgrade your TRT? thanks!

ttyio avatar Nov 03 '20 03:11 ttyio

@ttyio thanks. I have just tested this model in trt7.2, it works well:) And I am now testing more complicated models to see if there are other problems:)

chenbohua3 avatar Nov 03 '20 04:11 chenbohua3

Thanks @chenbohua3 , closing

ttyio avatar Nov 03 '20 04:11 ttyio

Hi, could you explain what cause this issue? @ttyio i have to deal with tensorrt version 6.5. And needs to know whats causing this error

mhmmdjafarg avatar Jun 11 '23 17:06 mhmmdjafarg