I have created an onnx model that successfully with TensorRT 7 on my host machine, but it gives the following error on AGX Xavier.
[TensorRT] ERROR: (Unnamed Layer* 0) [Convolution]: at least 5 dimensions are required for input
Traceback (most recent call last):
File “run.py”, line 49, in
engine = backend.prepare(model, device=‘CUDA:0’)
File “/home/yaak/onnx-tensorrt/onnx_tensorrt/backend.py”, line 200, in prepare
return TensorRTBackendRep(model, device, **kwargs)
File “/home/yaak/onnx-tensorrt/onnx_tensorrt/backend.py”, line 86, in init
raise RuntimeError(msg)
RuntimeError: While parsing node number 1:
builtin_op_importers.cpp:695 In function importBatchNormalization:
[6] Assertion failed: scale_weights.shape == weights_shape
I have converted the .pth to .onnx using torch 1.2.0 (also using the 1.3 gives the same error)
And used the following script to build a trt engine for it:
import onnx
import onnx_tensorrt.backend as backend
import numpy as np
Yes, I did go through the solutions proposed in this link.
I have installed TensorRT OSS v6.0 as well and have also tried to run the code with explicit batch flag. This is the script that I used with explicit batch flag:
import tensorrt as trt
def build_engine(onnx_path, engine_path):
TRT_LOGGER = trt.Logger()
with trt.Builder(TRT_LOGGER) as builder:
builder.max_workspace_size = 1 << 30 # 1GB
builder.max_batch_size = 1
builder.fp16_mode = True
#with builder.create_network() as network:
explicit_batch_flag = 1 << int(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)
with builder.create_network(explicit_batch_flag) as network:
with trt.OnnxParser(network, TRT_LOGGER) as parser:
with open(onnx_path, 'rb') as model:
print('here')
parser.parse(model.read())
print('here')
network.mark_output(network.get_layer(network.num_layers-1).get_output(0))
engine = builder.build_cuda_engine(network)
with open(engine_path, "wb") as f:
f.write(engine.serialize())
return engine
if __name__ == '__main__':
build_engine('model.onnx', 'model.engine')
The solution has not worked for me unfortunately. I still get the same error:
[TensorRT] ERROR: (Unnamed Layer* 0) [Convolution]: at least 5 dimensions are required for input
[TensorRT] WARNING: Setting layouts of network and plugin input/output tensors to linear, as 3D operators are found and 3D non-linear IO formats are not supported, yet.
[TensorRT] ERROR: (Unnamed Layer* 0) [Convolution]: at least 5 dimensions are required for input
Traceback (most recent call last):
File “run3.py”, line 26, in
build_engine(‘model.onnx’, ‘model.engine’)
File “run3.py”, line 22, in build_engine
f.write(engine.serialize())
AttributeError: ‘NoneType’ object has no attribute ‘serialize’
There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one. Thanks
Hi,
Sorry for the late update.
Would you mind to share the onnx file with us directly?