Segfault after nvinfer and custom parsing function

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
NVIDIA Jetson AGX

• DeepStream Version
Deepstream 6.2

• JetPack Version (valid for Jetson only)
JetPack 5.1-b147

• TensorRT Version
TensorRT 8.5.2.2-1+cuda11.4

• Issue Type( questions, new requirements, bugs)
Deepstream app is raising a Segmentation Fault error with the following setup.

Gst:
uridecodebin → nvvideoconvert → nvstreammux → nvinfer → logger → sink

nvinfer config file:

[property]
gpu-id=0
onnx-file=yolov7-tiny.onnx
gie-unique-id=1
model-engine-file=yolov7-tiny.onnx_b1_gpu0_fp32.engine
parse-bbox-func-name=NvDsInferParseCustomYOLOv7
custom-lib-path=/opt/nvidia/deepstream/deepstream-6.2/sources/libs/nvdsinfer_customparser/libnvds_infercustomparser.so

Custom Parsing function:

extern "C"
bool NvDsInferParseCustomYOLOv7 (
    std::vector<NvDsInferLayerInfo> const &outputLayersInfo,
    NvDsInferNetworkInfo  const &networkInfo,
    NvDsInferParseDetectionParams const &detectionParams,
    std::vector<NvDsInferObjectDetectionInfo> &objectList)
{
    const NvDsInferLayerInfo* numDetectionLayer = &outputLayersInfo[0];
    const NvDsInferLayerInfo* boxLayer = &outputLayersInfo[1];
    const NvDsInferLayerInfo* scoreLayer = &outputLayersInfo[2];
    const NvDsInferLayerInfo* classLayer = &outputLayersInfo[3];

    unsigned int numDetections = numDetectionLayer->inferDims.d[0];
    std::cout << "Number of detections " << numDetections << std::endl;

    for (unsigned int i =; i < numDetections; i++) {
        NvDsInferObjectDetectionInfo res;
        res.detectionConfidence = ((float*)scoreLayer->buffer)[i];
        res.classId = (unsigned int)((float*)classLayer->buffer)[i];

        float x1, y1, x2, y2;
        x1 = ((float*)boxLayer->buffer)[i*4 +0];
        y1 = ((float*)boxLayer->buffer)[i*4 +1];
        x2 = ((float*)boxLayer->buffer)[i*4 +2];
        y2 = ((float*)boxLayer->buffer)[i*4 +3];

        x1 = CLIP(x1, 0.0f, networkInfo.width -1);
        y1 = CLIP(y1, 0.0f, networkInfo.width -1);
        x2 = CLIP(x2, 0.0f, networkInfo.width -1);
        y2 = CLIP(y2, 0.0f, networkInfo.width -1);

        if ((x1 >= x2) || (y1 >= y2)) {
            continue;
        }

        res.left = x1;
        res.top = y1;
        res.width = (x2 - x1);
        res.height = (y2 - y1);

        if (res.width && res.height) {
            objectList.emplace_back(res);
        }
    }
    std::cout << "Exiting function " << std::endl;
    return true;
}

Model Inputs and outputs:

0   INPUT  kFLOAT images          3x640x640       
1   OUTPUT kINT32 num_dets        1               
2   OUTPUT kFLOAT det_boxes       100x4           
3   OUTPUT kFLOAT det_scores      100             
4   OUTPUT kINT32 det_classes     100

Console output:

0:00:07.760873598 84815     0x4167c390 INFO                 nvinfer gstnvinfer.cpp:680:gst_nvinfer_logger:<person-detector> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2012> [UID = 1]: Use deserialized engine model: /home/agx/Documents/detection_pipeline_gst/yolov7-tiny.onnx_b1_gpu0_fp32.engine
0:00:07.780071288 84815     0x4167c390 INFO                 nvinfer gstnvinfer_impl.cpp:328:notifyLoadModelStatus:<person-detector> [UID 1]: Load new model:yolo-config-ds.txt sucessfully

Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261 
Number of detections 1 
Exiting function 
Segmentation fault (core dumped)

Any tips on how to debug this will be helpful.

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

you can comment out some code in NvDsInferParseCustomYOLOv7 to check if it crashed in it. then please check which part code will cause crash.

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