Hardware Platform (Jetson / GPU) GPU DeepStream Version 7.0 TensorRT Version 8.6 NVIDIA GPU Driver Version (valid for GPU only) 550.120 Issue Type( questions, new requirements, bugs) questions, bugs
We encountered challenges where our model engine fails to build using nvinfer.
We run deepstream-test5-app with the configs below and our model.plan and custombbox parser
deepstream pipeline pgie setup
[primary-gie]
enable=1
gpu-id=0
#(0): nvinfer - Default inference plugin based on Tensorrt
#(1): nvinferserver - inference plugin based on Tensorrt-Inference-Server
plugin-type=0
model-engine-file=/opt/nvidia/deepstream/deepstream-7.0/model.plan
batch-size=32
#Required by the app for OSD, not a plugin property
bbox-border-color0=1;0;0;1
bbox-border-color1=0;1;1;1
bbox-border-color2=0;0;1;1
bbox-border-color3=0;1;0;1
interval=0
gie-unique-id=1
nvbuf-memory-type=0
config-file=/opt/nvidia/deepstream/deepstream-7.0/sources/apps/sample_apps/deepstream-test5/configs/config_infer_yolo.txt
from the error, the app failed to load the engine because unknown data type. nvinfer plugin is opensource. you can find this error in TrtEngine::getLayerInfo of \opt\nvidia\deepstream\deepstream\sources\libs\nvdsinfer\nvdsinfer_model_builder.cpp. you can add log to print the data type. if int64, this issue has been fixed in DS7.1. can you use DS7.1 or port the logics?
“type: 5” means “kUINT8 = 5,”. DS7.1 added a new type INT64, you can refer to this code. To be specific,
use the following steps to modify the code and build nvinfer low-level lib. especially please backup the original so first.
1.1 add a new UINT8 type in NvDsInferDataType of opt\nvidia\deepstream\deepstream\sources\includes\nvdsinfer.h
1.2 add a new UINT8 type in getElementSize of \opt\nvidia\deepstream\deepstream\sources\libs\nvdsinfer\nvdsinfer_func_utils.h.
1.3 add a new UINT8 type in dataType2Str of \opt\nvidia\deepstream\deepstream\sources\libs\nvdsinfer\nvdsinfer_func_utils.cpp
1.4 add a new UINT8 type in getLayerInfo of \opt\nvidia\deepstream\deepstream\sources\libs\nvdsinfer\nvdsinfer_model_builder.cpp
1.5 build nvifner, then replace /opt/nvidia/deepstream/deepstream/lib/libnvds_infer.so with the new so.
use the following steps to modify the code and build nvinfer plugin.
2.1 add a new UINT8 type in get_element_size of \opt\nvidia\deepstream\deepstream\sources\gst-plugins\gst-nvinfer\gstnvinfer.cpp
2.2 build nvinfer plugin, then replace libnvdsgst_infer.so with the new so.
I generated a yolov9 onnx model from this link by the following cmd, all the layer types are float32. from your screenshot, the input layer type is uint8. could you share the detailed steps to generate yolov9 model and TRT engine with uint8 type? Thanks! or could you share the onnx model by forum private email?
DeepStream7.0 nvinfer can support NHWC. please add the following configuration for nvinfer.
# 0=NCHW, 1=NHWC, 2=CUSTOM
network-input-order=1
Since the collor_space is BRG please add the following nvinfer configuration.
# 0=RGB, 1=BGR, 2=GRAY
model-color-format=1
Noticing “keep_ratio” is True. please set maintain-aspect-ratio=1.
if still can’t work, could you share the whole log? wondering if the engine was loaded. Since TRT engine is device dependent, it can’t be used in other devices. could you share the ONNX model if possible? Thanks!
Thanks for the modification. I think the network format is in sync with DeepStream (NHWC)
But after testing, there is dimension issue in the next step.
For the log, the app loaded the engine. but the engine is inconsistent with configurations. then the app tried to generate a new engine.
Please set infer-dims=3;640;640. nvinfer plugin parses this value by the format of “CHW”. please refer to gst_nvinfer_parse_props in \opt\nvidia\deepstream\deepstream-7.0\sources\gst-plugins\gst-nvinfer\gstnvinfer_property_parser.cpp.
I am confused about the dimension in the config.
Since we aligne the network to NHWC, it doesn’t mean that the infer dimension would be 640;640;3 ?
After setting infer-dims=3;640;640, the pipeline works, but it failed in the bbox parsing part (our parsing function).
the app crashed in the postprocessing function. nvinfer parse-bbox-func is different with nvinferserver custom_process_funcion. please refer to set1 and code2 for how to write nvinfer parse-bbox-func.
If you want to parse inference results directly, please set network-type=100 and output-tensor-meta=1, then parse the inference results in probe function. please refer to sample deepstream-infer-tensor-meta-test.
Our data scientist fixed the format and data type (uint8 input, channel last output, …) for easy development and alignment.
Is there recommendations on the data type/format with respect to performance?
@ronpai we fixed this issue of “Unknown data type for bound layer i(INPUT). type:5”. Using the model you provided in the email, we failed to generate TRT engine by trtexec or DeepStream. could you help to verify the fix in DS7.0 docker? Thank you! Here are the steps.
run fix.sh in the fix.zip (6.3 MB), which will copy so to libs. the fix code is in the “code” directory.
run “deepstream-test5-app -c configs/ds_yolov9_config.txt >1.log 2>1.log” to test your model with “type 5” input. then please share 1.log for further analysis. Thanks!