# How to load a etlt model in python script

**URL:** <https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896>\
**Category:** TAO Toolkit\
**Created:** [January 27, 2021, 5:55am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896 "2021-01-27T05:55:23Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![senbhaskar26](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@senbhaskar26](https://forums.developer.nvidia.com/u/senbhaskar26)\
**Post date:** [January 27, 2021, 5:55am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/1 "2021-01-27T05:55:23Z")

</div>

Hi … I have trained a detectnet\_v2 model of tlt-training toolkit with my custom dataset. I am able to get a .etlt file.  
Now my next step is that I need to make a module in python where I can load that .etlt model (file) and run predictions on sample images using that model.  
I need to know how I can do it ?

Any help will be appreciated.  
Thanks

---

<div class="post-metadata">

**Author:** ![Morganh](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/morganh/32/9748_2.png) [@Morganh](https://forums.developer.nvidia.com/u/Morganh)\
**Post date:** [January 27, 2021, 7:31am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/3 "2021-01-27T07:31:36Z")

</div>

You can generate trt engine based on the etlt model.  
Then load the engine in python script.  
Reference: [Run PeopleNet with tensorrt - #21 by carlos.alvarez](https://forums.developer.nvidia.com/t/run-peoplenet-with-tensorrt/128000/21)

---

<div class="post-metadata">

**Author:** ![senbhaskar26](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@senbhaskar26](https://forums.developer.nvidia.com/u/senbhaskar26)\
**Post date:** [January 27, 2021, 10:42am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/4 "2021-01-27T10:42:42Z")

</div>

hii… as per your suggestion i am using the script provide in the link.  
i have a model name :  
resnet18\_detector.etlt\_b1\_gpu0\_fp16.engine

after using this model i am getting error given below:

python3 tlt.py  
[TensorRT] ERROR: INVALID\_CONFIG: The engine plan file is generated on an incompatible device, expecting compute 5.3 got compute 7.2, please rebuild.  
[TensorRT] ERROR: engine.cpp (1546) - Serialization Error in deserialize: 0 (Core engine deserialization failure)  
[TensorRT] ERROR: INVALID\_STATE: std::exception  
[TensorRT] ERROR: INVALID\_CONFIG: Deserialize the cuda engine failed.  
Traceback (most recent call last):  
File “tlt.py”, line 243, in   
inputs, outputs, bindings, stream = allocate\_buffers(trt\_engine)  
File “tlt.py”, line 62, in allocate\_buffers  
for binding in engine:  
TypeError: ‘NoneType’ object is not iterable

any help regarding this issue ??  
thanks

---

<div class="post-metadata">

**Author:** ![Morganh](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/morganh/32/9748_2.png) [@Morganh](https://forums.developer.nvidia.com/u/Morganh)\
**Post date:** [January 27, 2021, 11:06am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/5 "2021-01-27T11:06:20Z")

</div>

Which device did you run inference?  
For example, if you want to run inference in Jetson Nano, you should download tlt-converter jetson version, copy etlt model into Nano and then generate trt engine in Nano.

---

<div class="post-metadata">

**Author:** ![senbhaskar26](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@senbhaskar26](https://forums.developer.nvidia.com/u/senbhaskar26)\
**Post date:** [January 27, 2021, 11:44am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/6 "2021-01-27T11:44:19Z")

</div>

what is the way ot convert the etlt model into engine file for jetson nano ? i cannot find the correct converter. @Morganh  
thanks

---

<div class="post-metadata">

**Author:** ![Morganh](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/morganh/32/9748_2.png) [@Morganh](https://forums.developer.nvidia.com/u/Morganh)\
**Post date:** [January 27, 2021, 12:28pm UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/7 "2021-01-27T12:28:18Z")

</div>

Refer to tlt user guide. [Integrating TAO Models into DeepStream — TAO Toolkit 3.22.05 documentation](https://docs.nvidia.com/metropolis/TLT/tlt-getting-started-guide/text/deploying_to_deepstream.html#instructions-for-jetson)

---

<div class="post-metadata">

**Author:** ![senbhaskar26](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@senbhaskar26](https://forums.developer.nvidia.com/u/senbhaskar26)\
**Post date:** [January 28, 2021, 3:57am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/8 "2021-01-28T03:57:37Z")

</div>

@Morganh  
after referring the documentation what you suggested, i am getting this error.

./tlt-converter -k OGQ4ZGw5cXN2M3QwNDJsNGxpbnRsNXJuOHY6OTQ4ZmU2ZTAtZDcyYy00MzE0LTk1ZjEtMTgyMDJkYWFIMDgw -d 3,384,1248 -o output\_bbox/BiasAdd,output\_cov/Sigmoid -e /home/senquire-nano/Documents -b 1 input\_file /home/senquire-nano/Documents/tlt\_exp\_niharika  
[ERROR] UffParser: Unsupported number of graph 0  
[ERROR] Failed to parse the model, please check the encoding key to make sure it’s correct  
[ERROR] Network must have at least one output  
[ERROR] Network validation failed.  
[ERROR] Unable to create engine  
Segmentation fault (core dumped).

Any idea?

thanks

---

<div class="post-metadata">

**Author:** ![Morganh](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/morganh/32/9748_2.png) [@Morganh](https://forums.developer.nvidia.com/u/Morganh)\
**Post date:** [January 28, 2021, 4:00am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/9 "2021-01-28T04:00:16Z")

</div>

You are missing etlt model file in your command line.  
Except tlt user guide, you can also trigger tlt docker and run its jupyter notebook to see how to run tlt-covnerter.

---

<div class="post-metadata">

**Author:** ![Morganh](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/morganh/32/9748_2.png) [@Morganh](https://forums.developer.nvidia.com/u/Morganh)\
**Post date:** [January 28, 2021, 4:01am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/10 "2021-01-28T04:01:48Z")

</div>

More refenence: [How to run tlt-converter](https://forums.developer.nvidia.com/t/how-to-run-tlt-converter/147299)

---

<div class="post-metadata">

**Author:** ![senbhaskar26](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@senbhaskar26](https://forums.developer.nvidia.com/u/senbhaskar26)\
**Post date:** [January 28, 2021, 4:15am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/11 "2021-01-28T04:15:15Z")

</div>

@Morganh  
still on the same page. not getting it exactly why this is happening.  
senquire-nano@senquire-nano:~/Downloads$ ./tlt-converter ./resnet18\_detector.etlt \

> -k OGQ4ZGw5cXN2M3QwNDJsNGxpbnRsNXJuOHY6OTQ4ZmU2ZTAtZDcyYy00MzE0LTk1ZjEtMTgyMDJkYWFIMDgw   
> -o output\_bbox/BiasAdd,output\_cov/Sigmoid -d 3,384,1248 -e resnet18\_detector.trt -b 1  
> [ERROR] UffParser: Unsupported number of graph 0  
> [ERROR] Failed to parse the model, please check the encoding key to make sure it’s correct  
> [ERROR] Network must have at least one output  
> [ERROR] Network validation failed.  
> [ERROR] Unable to create engine  
> Segmentation fault (core dumped)  
> thanks

---

<div class="post-metadata">

**Author:** ![Morganh](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/morganh/32/9748_2.png) [@Morganh](https://forums.developer.nvidia.com/u/Morganh)\
**Post date:** [January 28, 2021, 4:36am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/12 "2021-01-28T04:36:23Z")

</div>

Make sure your key is correct.

---

<div class="post-metadata">

**Author:** ![senbhaskar26](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@senbhaskar26](https://forums.developer.nvidia.com/u/senbhaskar26)\
**Post date:** [January 28, 2021, 4:37am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/13 "2021-01-28T04:37:39Z")

</div>

ok checking it once again. thanks

---

<div class="post-metadata">

**Author:** ![senbhaskar26](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@senbhaskar26](https://forums.developer.nvidia.com/u/senbhaskar26)\
**Post date:** [January 28, 2021, 5:20am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/14 "2021-01-28T05:20:59Z")

</div>

@Morganh  
now that error has gone and when i start i am getting this now.

[WARNING] Int8 support requested on hardware without native Int8 support, performance will be negatively affected.  
[INFO] Detected 1 inputs and 2 output network tensors.  
[INFO] Starting Calibration with batch size 1.  
[INFO] Post Processing Calibration data in 9.636e-06 seconds.  
[INFO] Calibration completed in 96.0879 seconds.  
[ERROR] Calibration failure occurred with no scaling factors detected. This could be due to no int8 calibrator or insufficient custom scales for network layers. Please see int8 sample to setup calibration correctly.  
[ERROR] Builder failed while configuring INT8 mode.  
[ERROR] Unable to create engine  
Segmentation fault (core dumped)

command which i ran is :  
./tlt-converter ./resnet18\_detector.etlt -k OGQ4ZGw5cXN2M3QwNDJsNGxpbnRsNXJuOHY6OTQ4ZmU2ZTAtZDcyYy00MzE0LTk1ZjEtMTgyMDJkYWFlMDgw -o output\_bbox/BiasAdd,output\_cov/Sigmoid -d 3,384,1248 -i nchw -m 64 -t int8 -e resnet18\_detector.trt -b 1  
thanks

---

<div class="post-metadata">

**Author:** ![Morganh](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/morganh/32/9748_2.png) [@Morganh](https://forums.developer.nvidia.com/u/Morganh)\
**Post date:** [January 28, 2021, 5:37am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/15 "2021-01-28T05:37:20Z")

</div>

You are missing “-c”. For int8 mode, “-c” is needed.  
Please refer to [How to run tlt-converter](https://forums.developer.nvidia.com/t/how-to-run-tlt-converter/147299)

---

<div class="post-metadata">

**Author:** ![senbhaskar26](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@senbhaskar26](https://forums.developer.nvidia.com/u/senbhaskar26)\
**Post date:** [January 28, 2021, 6:57am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/16 "2021-01-28T06:57:53Z")

</div>

@Morganh that error has gone finally able to generate an engine file or a trt file using tlt-converter. now trying to loading the engine file in the people net script, but getting errors like …  
Traceback (most recent call last):  
File “tlt.py”, line 250, in   
detection\_out, keepCount\_out = predict(image, model\_w, model\_h)  
File “tlt.py”, line 115, in predict  
img = process\_image(image, model\_w, model\_h)  
File “tlt.py”, line 96, in process\_image  
image = Image.fromarray(np.int(arr))  
TypeError: int() argument must be a string, a bytes-like object or a number, not ‘NoneType’

[tlt.py](https://forums.developer.nvidia.com/uploads/short-url/lZPI0tidozAbgbgXFklXygneKOZ.py) (8.6 KB)  
thanks

---

<div class="post-metadata">

**Author:** ![Morganh](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/morganh/32/9748_2.png) [@Morganh](https://forums.developer.nvidia.com/u/Morganh)\
**Post date:** [January 28, 2021, 7:01am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/17 "2021-01-28T07:01:01Z")

</div>

Please debug by yourself. I recall that other user can run that script well according the feedback from

> [@Inferring detectnet\_v2 .trt model in python](https://forums.developer.nvidia.com/t/inferring-detectnet-v2-trt-model-in-python/165403/4):
>
> Hi @Morganh, Thanks, it worked for detectnet\_v2 made .trt file inference. But now i created a .engine file using yolo. And i am getting the following error. I am running it inside the container itself with my code. [TensorRT] ERROR: INVALID\_ARGUMENT: getPluginCreator could not find plugin BatchTilePlugin\_TRT version 1 [TensorRT] ERROR: safeDeserializationUtils.cpp (293) - Serialization Error in load: 0 (Cannot deserialize plugin since corresponding IPluginCreator not found in Plugin Registry) …

---

<div class="post-metadata">

**Author:** ![senbhaskar26](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@senbhaskar26](https://forums.developer.nvidia.com/u/senbhaskar26)\
**Post date:** [January 28, 2021, 7:15am UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/18 "2021-01-28T07:15:12Z")

</div>

@Morganh thanks a lot . i am able to run it end to end for detectnet .  
thanks

---

<div class="post-metadata">

**Author:** ![TomNVIDIA](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tomnvidia/32/14181_2.png) [@TomNVIDIA](https://forums.developer.nvidia.com/u/TomNVIDIA)\
**Post date:** [October 12, 2021, 4:24pm UTC](https://forums.developer.nvidia.com/t/how-to-load-a-etlt-model-in-python-script/166896/20 "2021-10-12T16:24:05Z")

</div>

Closed on October 12, 2021, 4:24pm UTC


