Not able to convert onnx file to engine file for Deepstream 7.1

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
• DeepStream Version 7.1
• JetPack Version 6.2
• TensorRT Version 10.8
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

i have converted the onnx model into engine model using the below cmd:

/usr/src/tensorrt/bin/trtexec --onnx=/home/parkzap/deepstream-python/models/lpdnet/LPDNet_usa_pruned_tao5.onnx
–maxShapes=“input_1:0”:0x3x480x640
–minShapes=“input_1:0”:0x3x480x640
–optShapes=“input_1:0”:0x3x480x640
–fp16
–saveEngine=/home/parkzap/deepstream-python/models/yolov4_tiny.engine

this is the pgie config file that i am using:

[property]
gpu-id=0
net-scale-factor=1.0
offsets=77.5;21.2;11.8
model-color-format=0
#model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel
#proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt
#tlt-encoded-model=/home/parkzap/deepstream-python/models/yolov4_tiny_usa_deployable.etlt
#tlt-model-key=nvidia_tlt
#model-engine-file=/home/parkzap/deepstream-python/models/yolov4_tiny_usa_deployable.etlt_b16_gpu0_fp16.engine
model-engine-file=/home/parkzap/deepstream-python/models/yolov4_tiny3.engine
labelfile-path=/home/parkzap/deepstream-python/TAO/labels_lpdnet.txt
int8-calib-file=/home/parkzap/deepstream-python/TAO/yolov4_tiny_usa_cal.bin
#operate-on-gie-id=1
#operate-on-class-ids=0
force-implicit-batch-dim=1
batch-size=11
process-mode=1
network-mode=1
num-detected-classes=1
interval=0
gie-unique-id=2
output-blob-names=BatchedNMS
parse-bbox-func-name=NvDsInferParseCustomBatchedNMSTLT
custom-lib-path=/home/parkzap/deepstream-python/TAO/libnvds_infercustomparser_tao.so
#scaling-compute-hw=0
maintain-aspect-ratio=0

#enable-dla=1
#use-dla-core=0

#workspace-size=400

cluster-mode=4
output-tensor-meta=0
network-type=0

[class-attrs-all]
#pre-cluster-threshold=0.85
eps=0.2
group-threshold=1
post-cluster-threshold=0.5
dbscan-min-score=0.5
nms-iou-threshold=0.5
topk=2
#threshold=0.6
#threshold=0.8

#roi - region of interest
roi-top-offset=80
roi-bottom-offset=50
#detected-min-w=50
#detected-min-h=10
#detected-max-w=300
#detected-max-h=150

i am getting this error :

RTO S

########## color detection Can be enabled using redis key (COLOR = 1) ###########
Creating source_bin 0

*** DeepStream: Playing from source 0: file:///home/parkzap/VJ_3.mp4 ***

Creating H264 Encoder
Creating H264 rtppay
Creating nvdsanalytics

Playing file file:///home/parkzap/VJ_3.mp4
Linking elements in the Pipeline

*** DeepStream: Launched RTSP Streaming at rtsp://localhost:8554/test ***

Starting pipeline

Opening in BLOCKING MODE
Setting min object dimensions as 16x16 instead of 1x1 to support VIC compute mode.
ERROR: [TRT]: IRuntime::deserializeCudaEngine: Error Code 1: Serialization (Serialization assertion plan->header.magicTag == rt::kPLAN_MAGIC_TAG failed.Trying to load an engine created with incompatible serialization version. Check that the engine was not created using safety runtime, same OS was used and version compatibility parameters were set accordingly.)
ERROR: Deserialize engine failed from file: /home/parkzap/deepstream-python/models/lprnet_epoch-020_80-20.onnx_b16_gpu0_fp16.engine
0:00:00.339085991 44964 0xaaaae0cbcb60 WARN nvinfer gstnvinfer.cpp:681:gst_nvinfer_logger: NvDsInferContext[UID 3]: Warning from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:2080> [UID = 3]: deserialize engine from file :/home/parkzap/deepstream-python/models/lprnet_epoch-020_80-20.onnx_b16_gpu0_fp16.engine failed
0:00:00.339138089 44964 0xaaaae0cbcb60 WARN nvinfer gstnvinfer.cpp:681:gst_nvinfer_logger: NvDsInferContext[UID 3]: Warning from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2185> [UID = 3]: deserialize backend context from engine from file :/home/parkzap/deepstream-python/models/lprnet_epoch-020_80-20.onnx_b16_gpu0_fp16.engine failed, try rebuild
0:00:00.339154377 44964 0xaaaae0cbcb60 INFO nvinfer gstnvinfer.cpp:684:gst_nvinfer_logger: NvDsInferContext[UID 3]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:2106> [UID = 3]: Trying to create engine from model files
WARNING: [TRT]: ModelImporter.cpp:797: Make sure output tf_op_layer_ArgMax has Int64 binding.
WARNING: [TRT]: DLA requests all profiles have same min, max, and opt value. All dla layers are falling back to GPU
WARNING: in op re_lu_16_clip_min, operand re_lu_16_clip_beta payload type requires precision-lose casting
WARNING: in op re_lu_16_clip_min, operand re_lu_16_clip_beta payload type requires precision-lose casting
0:02:57.847224982 44964 0xaaaae0cbcb60 INFO nvinfer gstnvinfer.cpp:684:gst_nvinfer_logger: NvDsInferContext[UID 3]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:2138> [UID = 3]: serialize cuda engine to file: /home/parkzap/deepstream-python/models/lprnet_epoch-020_80-20.onnx_b11_gpu0_fp16.engine successfully
INFO: [FullDims Engine Info]: layers num: 3
0 INPUT kFLOAT image_input 3x48x106 min: 1x3x48x106 opt: 11x3x48x106 Max: 11x3x48x106
1 OUTPUT kINT64 tf_op_layer_ArgMax 27 min: 0 opt: 0 Max: 0
2 OUTPUT kFLOAT tf_op_layer_Max 27 min: 0 opt: 0 Max: 0

0:02:58.318563142 44964 0xaaaae0cbcb60 INFO nvinfer gstnvinfer_impl.cpp:343:notifyLoadModelStatus: [UID 3]: Load new model:config/sgie_config_ResNet.txt sucessfully
gstnvtracker: Loading low-level lib at /opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so
[NvMultiObjectTracker] Initialized
Setting min object dimensions as 16x16 instead of 1x1 to support VIC compute mode.
0:02:58.394320606 44964 0xaaaae0cbcb60 WARN nvinfer gstnvinfer.cpp:681:gst_nvinfer_logger: NvDsInferContext[UID 2]: Warning from NvDsInferContextImpl::initialize() <nvdsinfer_context_impl.cpp:1243> [UID = 2]: Warning, OpenCV has been deprecated. Using NMS for clustering instead of cv::groupRectangles with topK = 20 and NMS Threshold = 0.5
0:02:58.394922510 44964 0xaaaae0cbcb60 INFO nvinfer gstnvinfer.cpp:684:gst_nvinfer_logger: NvDsInferContext[UID 2]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:2106> [UID = 2]: Trying to create engine from model files
Implicit layer support has been deprecated
ERROR: [TRT]: IBuilder::buildSerializedNetwork: Error Code 4: API Usage Error (Network has dynamic or shape inputs, but no optimization profile has been defined.)
Segmentation fault (core dumped)
parkzap@ubuntu:~/deepstream-python$

Could you modify the 1st dim from ‘0’ to ‘1’?

Tried replacing 0 dim with 1 as you suggested, but still the same issue.

*** DeepStream: Launched RTSP Streaming at rtsp://localhost:8554/test ***

Starting pipeline

Opening in BLOCKING MODE
Setting min object dimensions as 16x16 instead of 1x1 to support VIC compute mode.
ERROR: [TRT]: IRuntime::deserializeCudaEngine: Error Code 1: Serialization (Serialization assertion plan->header.magicTag == rt::kPLAN_MAGIC_TAG failed.Trying to load an engine created with incompatible serialization version. Check that the engine was not created using safety runtime, same OS was used and version compatibility parameters were set accordingly.)
ERROR: Deserialize engine failed from file: /home/parkzap/deepstream-python/models/lprnet_epoch-020_80-20.onnx_b16_gpu0_fp16.engine
0:00:00.339911628 97137 0xaaaaea3bab60 WARN nvinfer gstnvinfer.cpp:681:gst_nvinfer_logger: NvDsInferContext[UID 3]: Warning from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:2080> [UID = 3]: deserialize engine from file :/home/parkzap/deepstream-python/models/lprnet_epoch-020_80-20.onnx_b16_gpu0_fp16.engine failed
0:00:00.339960014 97137 0xaaaaea3bab60 WARN nvinfer gstnvinfer.cpp:681:gst_nvinfer_logger: NvDsInferContext[UID 3]: Warning from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2185> [UID = 3]: deserialize backend context from engine from file :/home/parkzap/deepstream-python/models/lprnet_epoch-020_80-20.onnx_b16_gpu0_fp16.engine failed, try rebuild
0:00:00.339976111 97137 0xaaaaea3bab60 INFO nvinfer gstnvinfer.cpp:684:gst_nvinfer_logger: NvDsInferContext[UID 3]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:2106> [UID = 3]: Trying to create engine from model files
WARNING: [TRT]: ModelImporter.cpp:797: Make sure output tf_op_layer_ArgMax has Int64 binding.
WARNING: [TRT]: DLA requests all profiles have same min, max, and opt value. All dla layers are falling back to GPU
WARNING: in op re_lu_16_clip_min, operand re_lu_16_clip_beta payload type requires precision-lose casting
WARNING: in op re_lu_16_clip_min, operand re_lu_16_clip_beta payload type requires precision-lose casting
0:02:59.278471745 97137 0xaaaaea3bab60 INFO nvinfer gstnvinfer.cpp:684:gst_nvinfer_logger: NvDsInferContext[UID 3]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:2138> [UID = 3]: serialize cuda engine to file: /home/parkzap/deepstream-python/models/lprnet_epoch-020_80-20.onnx_b11_gpu0_fp16.engine successfully
INFO: [FullDims Engine Info]: layers num: 3
0 INPUT kFLOAT image_input 3x48x106 min: 1x3x48x106 opt: 11x3x48x106 Max: 11x3x48x106
1 OUTPUT kINT64 tf_op_layer_ArgMax 27 min: 0 opt: 0 Max: 0
2 OUTPUT kFLOAT tf_op_layer_Max 27 min: 0 opt: 0 Max: 0

0:02:59.753711332 97137 0xaaaaea3bab60 INFO nvinfer gstnvinfer_impl.cpp:343:notifyLoadModelStatus: [UID 3]: Load new model:config/sgie_config_ResNet.txt sucessfully
gstnvtracker: Loading low-level lib at /opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so
[NvMultiObjectTracker] Initialized
Setting min object dimensions as 16x16 instead of 1x1 to support VIC compute mode.
0:02:59.830410282 97137 0xaaaaea3bab60 WARN nvinfer gstnvinfer.cpp:681:gst_nvinfer_logger: NvDsInferContext[UID 2]: Warning from NvDsInferContextImpl::initialize() <nvdsinfer_context_impl.cpp:1243> [UID = 2]: Warning, OpenCV has been deprecated. Using NMS for clustering instead of cv::groupRectangles with topK = 20 and NMS Threshold = 0.5
0:02:59.831024995 97137 0xaaaaea3bab60 INFO nvinfer gstnvinfer.cpp:684:gst_nvinfer_logger: NvDsInferContext[UID 2]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:2106> [UID = 2]: Trying to create engine from model files
Implicit layer support has been deprecated
ERROR: [TRT]: IBuilder::buildSerializedNetwork: Error Code 4: API Usage Error (Network has dynamic or shape inputs, but no optimization profile has been defined.)
Segmentation fault (core dumped)
parkzap@ubuntu:~/deepstream-python$ python3 single_stream.py file:///home/parkzap/VJ_

this is th shape of the input tensor

Have yo modified the engine file in your config file to the newly generated one?

We have many similar samples. Please refer the samples below first.
trtexec command: build_triton_engine.sh

config file: configs

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

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