Getting Error when trying to upload .TRT model

I am trying to run this code :

import tensorrt as trt
import pycuda.driver as cuda
import pycuda.autoinit

f = open(“resnet18_detector.trt”, “rb”)
#f = open(“resnet_engine.trt”, “rb”)

runtime = trt.Runtime(trt.Logger(trt.Logger.WARNING))

engine = runtime.deserialize_cuda_engine(
context = engine.create_execution_context()

I am getting this error
AttributeError Traceback (most recent call last)
10 engine = runtime.deserialize_cuda_engine(
—> 11 context = engine.create_execution_context()

AttributeError: ‘NoneType’ object has no attribute ‘create_execution_context’

I run
• Hardware Platform (Jetson / GPU): Tesla T4
•Transfere learning Toolkit: 3.0
• TensorRT Version** : 7.2.1-1+cuda11.1
• NVIDIA GPU Driver Version (valid for GPU only)** : cuda_11.1

Which network did you run? Have you run inference well with the tlt model? For example, run with deepstream-app.

Please make sure you build TRT OSS plugin and replace it.

Reference: Inferring detectnet_v2 .trt model in python

1- I trained my model using FaceDetect model from this notebook facenet/facenet.ipynb
found in this link:

2- I run inference well in TLT and Deepstream.

3- I uploaded the model
resnet18_detector.trt (13.3 MB)

The facedetect model is based on the NVIDIA DetectNet_v2 detector with ResNet18 as a feature extractor.
For trt engine inference, you can refer to Run PeopleNet with tensorrt - #21 by carlos.alvarez

I tried it and I got this error:


TypeError Traceback (most recent call last)
10 # This allocates memory for network inputs/outputs on both CPU and GPU
—> 11 inputs, outputs, bindings, stream = allocate_buffers(trt_engine)
13 # Execution context is needed for inference

in allocate_buffers(engine, batch_size)
48 }
—> 50 for binding in engine:
51 size = trt.volume(engine.get_binding_shape(binding)) * batch_size
52 dtype = binding_to_type[str(binding)]

TypeError: ‘NoneType’ object is not iterable

Can you try to debug more by yourself? Other users can run it successfully.

Is there any guideline to run .trt or .etlt or .tlt models on python ?

1 Like

For .tlt model or .trt engine, end user can run with default tlt detectnet_v2 inference to do inference.
For .etlt model, end user can deploy it with deepstream.
For .trt engine, if you try to run with your own python code, you can refer to Developer Guide :: NVIDIA Deep Learning TensorRT Documentation , mentioned in Inferring resnet18 classification etlt model with python - #12 by Morganh

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.