ERROR: ModelImporter.cpp:296 In function importModel: [5] Assertion failed: tensors.count(input_name...


I have export moded to onnx format using the below command.
python3.6 --model-dir=cat

And when I try to use this onnx model using the command “python3.6 --model=/home/shankar/shankar/resnet18.onnx --input_blob=input_0 --output_blob=output_0 --labels=~/datasets/cat/labels.txt ~/datasets/cat/test/02.jpg cat.jpg” , I get the below error.

WARNING: ONNX model has a newer ir_version (0.0.4) than this parser was built against (0.0.3).
While parsing node number 0 [Conv]:
ERROR: ModelImporter.cpp:296 In function importModel:
[5] Assertion failed: tensors.count(input_name)
[TRT] failed to parse ONNX model ‘/home/shankar/shankar/resnet18.onnx’
[TRT] device GPU, failed to load /home/shankar/shankar/resnet18.onnx
[TRT] failed to load /home/shankar/shankar/resnet18.onnx
[TRT] imageNet – failed to initialize.

Please suggest fix for this.

I am using the latest jetson nano image r32.3.1 (released on dec 10th 2019).
Python: 3.6
PyTorch v1.3.0
Torchvision v0.5.0

I tried to downgrade pytorch to version 1.2, but could not get proper working clone link to do it. I did downgrade to version 1.1 and tried, but getting the same error.

Let me know the right git clone path and commands to install pytorch version 1.2.0.


  1. For cloning the PyTorch 1.2.0 branch (tag), you can do this:
$ git clone --branch=v1.2.0

And you can verify it’s correct by checking the last commit:

$ cd pytorch/
$ git log -1
commit 54a63e0420c2810930d848842142a07071204c06 (HEAD -> v1.2.0, origin/v1.2.0)
Author: Jessica Lin <>
Date:   Tue Oct 1 18:52:53 2019 -0700

    Update header names and add in C++ docs (#27172)

    1. Update "Package Reference" to "Python API"
    2. Add in torchaudio and torchtext reference links so they show up across all docs not just the main page
    3. Add "Other Languages" section and add in C++ docs
  1. For the original question, I’m going to move this to the Jetson Nano forum.

Thanks Jessica. I am able to git clone version 1.2.0 and install it. But with this also, I am still getting the same error “ERROR: ModelImporter.cpp:296 In function importModel:”.

I also tried re training the model using the command “python3.6 --model-dir=cat ~/datasets/cat”. For this I am getting the error “ImportError: cannot import name ‘Optional’”.
This is a new problem with pytorch version 1.2.0, I was not getting this with version 1.3.0.

PLease suggest whats going wrong here…


Not sure which model do you use.
But the import error looks like your model is not supported.

Could you check if this issue helps first?