TensorRT Python parse report an error - Failed to add input to the network


I’m using both TRT Python and C++ versions to inference my onnx model.
While I’m getting to activate the onnx parse operation, only C++ version is successfully completed and no error is reported while the Python raise an error -
*In node -1 (importInput): UNSUPPORTED_NODE: Assertion failed: (tensor = ctx->network()->addInput(input.name().c_str(), trtDtype, trt_dims)) && "Failed to add input to the network.


TensorRT Version:
GPU Type: GeForce GTX 1080
Nvidia Driver Version: 460.32.03
CUDA Version: 11.2
CUDNN Version: 8.2.1
Operating System + Version: Linux Ubuntu 18.04
Python Version (if applicable): 3.6.9
TensorFlow Version (if applicable): NA
PyTorch Version (if applicable): NA
Baremetal or Container (if container which image + tag): Baremetal

Relevant Files

Onnx model

Steps To Reproduce

        self.logger = trt.Logger(trt.Logger.INTERNAL_ERROR)

        self.builder = trt.Builder(self.logger)
        self.builder.max_batch_size = maxBatchSize

        self.config = self.builder.create_builder_config()

        self.EXPLICIT_BATCH = 1 << (int)(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)
        self.network = self.builder.create_network(self.EXPLICIT_BATCH)
        self.parser = trt.OnnxParser(self.network, self.logger)
        self.runtime = trt.Runtime(self.logger)
        self.model = model
            parseResult = self.parser.parse_from_file(self.modelPath)
        except BaseException as e:
            msg = e
            self.isParsed = False
            print(ca.bcolors.FAIL + 'TRT parse model ERROR - ', msg)

        if(self.isParsed == True):
            print(ca.bcolors.HEADER + 'Completed Onnx file parsing')
            print(ca.bcolors.HEADER + "TensorRT model parse report:")
            if (not parseResult):
                for error in range(self.parser.num_errors):
                    print(ca.bcolors.FAIL + str(self.parser.get_error(error)))
                print(ca.bcolors.OKGREEN + "Model parsing OK!")



Please refer python samples here and make sure your script is correct.

If you still face this issue we recommend you to please share complete issue repro script with sample input to try from our end and also verbose error logs for better debugging.

Thank you.