tensorrt 6.0.1.5 torch1.3 onnx, build engine from onnx file fail, Network must have at least one out...

def simple_conv1d():
    class TestNet(torch.nn.Module):
        def __init__(self):
            super(TestNet, self).__init__()
            self.conv = torch.nn.Conv1d(2, 4, kernel_size=(1,))
            return
        def forward(self, x):
            res = self.conv(x)
            return res
    x = torch.randn(3, 2, 10)
    net = TestNet()
    onnx_file_path = "simple_conv1d.onnx"
    torch.onnx.export(net, x, onnx_file_path, export_params=True, verbose=True, input_names=["data"])
    TRT_LOGGER = trt.Logger(trt.Logger.INFO)
    with trt.Builder(TRT_LOGGER) as builder:
        with builder.create_network() as network:
            with trt.OnnxParser(network,TRT_LOGGER) as parser:
                with open(onnx_file_path, 'rb') as model:
                    parser.parse(model.read())
                builder.max_workspace_size = 1<<30
                builder.fp16_mode = False
                builder.max_batch_size = 32
                builder.strict_type_constraints = False
                engine = builder.build_cuda_engine(network)
                with open("simple_conv1d.trt", "wb") as f:
                    f.write(engine.serialize())
    return

even such simple conv1d still fail…
got error

[TensorRT] ERROR: Network must have at least one output

This specific issue is arising because the ONNX Parser isn’t currently compatible with the ONNX models exported from Pytorch 1.3 - If you downgrade to Pytorch 1.2, this issue should go away.

See related issue on GitHub: https://github.com/NVIDIA/TensorRT/issues/220#issuecomment-553723987