Open MHGL opened 3 years ago
我在转化yolov5时遇到了同样的错误,我在Tensorrt那边看到了这个issue,我再max更改为2016工作正常,我觉的max input可能跟模型的stride有关
单纯的5次下采样并不会引发这个错误,还需要在最后的feature上上采样+cat操作。 这个问题很奇怪,有时可以正常运行,会出现
[TensorRT] WARNING: Max value of this profile is not valid
,就只是warning;有的时候就是直接报错了。暂时没有能力深究原因,等下官方吧。
I encountered the same problem in 8.5GA version, I set min HW dims to a number greater than 1, the problem seems to be solved. However, there is fine when I using 8.2 version. It seems that TensorRT add some check for invalid dynamic dims .
question
I get this error while convert module to tensorrt
To Reproduce
Steps to reproduce the behavior:
class MyModule(torch.nn.Module): def init(self): super(MyModule, self).init() for i in range(1, 6): setattr(self, f"down{i}", torch.nn.Conv2d(3, 3, 3, 2, padding=1))
torch_model = MyModule()
torch.onnx.export
torch.onnx.export(torch_model, torch.randn(1, 3, 224, 224), "./tmp.onnx", input_names=["inputs"], output_names=["outputs"], dynamic_axes={"inputs": {0: "batch", 2: "height", 3: "width"}, "outputs": {0: "batch", 1: "class", 2: "height", 3: "width"}}, opset_version=11, export_params=True)
import os onnx_file = os.path.join(os.getcwd(), "tmp.onnx")
onnx -> tensorrt
!!!
you should build tensorrt first
import tensorrt as trt
TRT_LOGGER = trt.Logger(trt.Logger.WARNING) with trt.Builder(TRT_LOGGER) as builder, builder.create_network(1 << (int)(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)) as network, trt.OnnxParser(network, TRT_LOGGER) as parser: with open(onnx_file, 'rb') as model: parser.parse(model.read())
Expected behavior
Environment