marcoslucianops / DeepStream-Yolo

NVIDIA DeepStream SDK 7.0 / 6.4 / 6.3 / 6.2 / 6.1.1 / 6.1 / 6.0.1 / 6.0 / 5.1 implementation for YOLO models
MIT License
1.45k stars 357 forks source link

Uncertain or not enough buffers, enabling copy threshold Segmentation fault #383

Open zardadi opened 1 year ago

zardadi commented 1 year ago

Trying to run yolov5 engine file on Jetson, orin I am running DS 6.2. I passed Onnx file in config file. Deepstream could generate engine file successfully, but deepstream can’t run the pipeline to start inference and got the following error:

Runtime commands:
        h: Print this help
        q: Quit

        p: Pause
        r: Resume

** INFO: <bus_callback:239>: Pipeline ready

0:00:03.830428023 46006 0xaaab04fe5b00 WARN                 qtdemux qtdemux_types.c:239:qtdemux_type_get: unknown QuickTime node type pasp
0:00:03.830502584 46006 0xaaab04fe5b00 WARN                 qtdemux qtdemux.c:3250:qtdemux_parse_trex:<qtdemux0> failed to find fragment defaults for stream 1
Opening in BLOCKING MODE
0:00:03.866730226 46006 0xffff040529e0 WARN                    v4l2 gstv4l2object.c:4512:gst_v4l2_object_probe_caps:<nvv4l2decoder0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:03.866778450 46006 0xffff040529e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xfffefc01a010 Failed to determine interlace mode
0:00:03.866804467 46006 0xffff040529e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xfffefc01a010 Failed to determine interlace mode
0:00:03.866824467 46006 0xffff040529e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xfffefc01a010 Failed to determine interlace mode
0:00:03.866842867 46006 0xffff040529e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xfffefc01a010 Failed to determine interlace mode
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
0:00:03.971916810 46006 0xffff040529e0 WARN                    v4l2 gstv4l2object.c:4512:gst_v4l2_object_probe_caps:<nvv4l2decoder0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:03.971977931 46006 0xffff040529e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xfffefc01a010 Failed to determine interlace mode
0:00:03.972003787 46006 0xffff040529e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xfffefc01a010 Failed to determine interlace mode
0:00:03.972018476 46006 0xffff040529e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xfffefc01a010 Failed to determine interlace mode
0:00:03.972032524 46006 0xffff040529e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xfffefc01a010 Failed to determine interlace mode
0:00:03.974525521 46006 0xffff040529e0 WARN            v4l2videodec gstv4l2videodec.c:1880:gst_v4l2_video_dec_decide_allocation:<nvv4l2decoder0> Duration invalid, not setting latency
** INFO: <bus_callback:225>: Pipeline running

0:00:03.978452555 46006 0xffff040529e0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1114:gst_v4l2_buffer_pool_start:<nvv4l2decoder0:pool:src> Uncertain or not enough buffers, enabling copy threshold
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
0:00:04.004423148 46006 0xffff0800a180 WARN          v4l2bufferpool gstv4l2bufferpool.c:1565:gst_v4l2_buffer_pool_dqbuf:<nvv4l2decoder0:pool:src> Driver should never set v4l2_buffer.field to ANY
0:00:04.005385147 46006 0xaaaae8daf1e0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1114:gst_v4l2_buffer_pool_start:<sink_sub_bin_encoder1:pool:src> Uncertain or not enough buffers, enabling copy threshold
Segmentation fault

Environment

TensorRT Version: 8.5.2-1+cuda11.4 GPU Type: Jetson Orin Nvidia Driver Version: Jetson Orin CUDA Version: 11.4 CUDNN Version: 8.6.0.166-1+cuda11.4 arm64 Operating System + Version: Ubuntu 20.04 Python Version (if applicable): NA TensorFlow Version (if applicable): NA PyTorch Version (if applicable): NA Baremetal or Container (if container which image + tag): Baremetal

Steps To Reproduce $ Deepstream-app -c deepstream-app-config.txt

marcoslucianops commented 1 year ago

Can you send me the full log from the terminal and your config_infer_primary_yoloV5.txt file?

marcoslucianops commented 1 year ago

And the `deepstream_app_config.txt``file.

zardadi commented 1 year ago

@marcoslucianops , thanks for your reply. I run GST_DEBUG=2 deepstream-app -c deepstream_app_config.txt to get more details fo the error. Below is the full log from the terminal.

Opening in BLOCKING MODE 
0:00:00.100849936 107195 0xaaaace331aa0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xaaaace01c180 Failed to determine interlace mode
0:00:00.100905713 107195 0xaaaace331aa0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xaaaace01c180 Failed to determine interlace mode
0:00:00.100928465 107195 0xaaaace331aa0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xaaaace01c180 Failed to determine interlace mode
0:00:00.100945777 107195 0xaaaace331aa0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xaaaace01c180 Failed to determine interlace mode
0:00:00.101010642 107195 0xaaaace331aa0 WARN                    v4l2 gstv4l2object.c:4512:gst_v4l2_object_probe_caps:<sink_sub_bin_encoder1:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:02.746773501 107195 0xaaaace331aa0 INFO                 nvinfer gstnvinfer.cpp:680:gst_nvinfer_logger:<primary_gie> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1909> [UID = 1]: deserialized trt engine from :/home/DeepStream-Yolo/yolov5lv6.1_img640_class9_fp16.engine
WARNING: [TRT]: The getMaxBatchSize() function should not be used with an engine built from a network created with NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag. This function will always return 1.
INFO: [Implicit Engine Info]: layers num: 2
0   INPUT  kFLOAT input           3x640x640       
1   OUTPUT kFLOAT output          25200x6         

0:00:02.916267621 107195 0xaaaace331aa0 INFO                 nvinfer gstnvinfer.cpp:680:gst_nvinfer_logger:<primary_gie> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2012> [UID = 1]: Use deserialized engine model:/home/DeepStream-Yolo/yolov5lv6.1_img640_class9_fp16.engine
0:00:02.945555245 107195 0xaaaace331aa0 INFO                 nvinfer gstnvinfer_impl.cpp:328:notifyLoadModelStatus:<primary_gie> [UID 1]: Load new model:/home/DeepStream-Yolo/config_infer_primary_yoloV5.txt sucessfully
0:00:02.946657983 107195 0xaaaace331aa0 WARN                 basesrc gstbasesrc.c:3600:gst_base_src_start_complete:<source> pad not activated yet
0:00:02.947216872 107195 0xaaaace331aa0 WARN                 basesrc gstbasesrc.c:3600:gst_base_src_start_complete:<source> pad not activated yet

Runtime commands:
        h: Print this help
        q: Quit

        p: Pause
        r: Resume

** INFO: <bus_callback:239>: Pipeline ready

0:00:02.951004999 107195 0xaaaaeb679b00 WARN                 qtdemux qtdemux_types.c:239:qtdemux_type_get: unknown QuickTime node type pasp
0:00:02.951092425 107195 0xaaaaeb679b00 WARN                 qtdemux qtdemux.c:3250:qtdemux_parse_trex:<qtdemux0> failed to find fragment defaults for stream 1
Opening in BLOCKING MODE 
0:00:02.983389091 107195 0xffff100519e0 WARN                    v4l2 gstv4l2object.c:4512:gst_v4l2_object_probe_caps:<nvv4l2decoder0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:02.983432996 107195 0xffff100519e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xffff08015450 Failed to determine interlace mode
0:00:02.983466724 107195 0xffff100519e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xffff08015450 Failed to determine interlace mode
0:00:02.983487749 107195 0xffff100519e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xffff08015450 Failed to determine interlace mode
0:00:02.983509829 107195 0xffff100519e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xffff08015450 Failed to determine interlace mode
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261 
0:00:03.088406488 107195 0xffff100519e0 WARN                    v4l2 gstv4l2object.c:4512:gst_v4l2_object_probe_caps:<nvv4l2decoder0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:03.088441049 107195 0xffff100519e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xffff08015450 Failed to determine interlace mode
0:00:03.088466777 107195 0xffff100519e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xffff08015450 Failed to determine interlace mode
0:00:03.088481145 107195 0xffff100519e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xffff08015450 Failed to determine interlace mode
0:00:03.088494618 107195 0xffff100519e0 WARN                    v4l2 gstv4l2object.c:2398:gst_v4l2_object_add_interlace_mode:0xffff08015450 Failed to determine interlace mode
** INFO: <bus_callback:225>: Pipeline running

0:00:03.090514523 107195 0xffff100519e0 WARN            v4l2videodec gstv4l2videodec.c:1880:gst_v4l2_video_dec_decide_allocation:<nvv4l2decoder0> Duration invalid, not setting latency
0:00:03.090726015 107195 0xffff100519e0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1114:gst_v4l2_buffer_pool_start:<nvv4l2decoder0:pool:src> Uncertain or not enough buffers, enabling copy threshold
NvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
0:00:03.121188570 107195 0xaaaace3029e0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1114:gst_v4l2_buffer_pool_start:<sink_sub_bin_encoder1:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:00:03.123351326 107195 0xffff14021d80 WARN          v4l2bufferpool gstv4l2bufferpool.c:1565:gst_v4l2_buffer_pool_dqbuf:<nvv4l2decoder0:pool:src> Driver should never set v4l2_buffer.field to ANY
Segmentation fault

config_infer_primary_yoloV5.txt:

[property]
gpu-id=0
net-scale-factor=0.0039215697906911373
model-color-format=0
onnx-file=yolov5lv6.1_img640_class9.onnx
model-engine-file=yolov5lv6.1_img640_class9_fp16.engine
#int8-calib-file=calib.table
labelfile-path=labels.txt
batch-size=1 # number of frames for inference
network-mode=2 # 0:fp32 1:int8 2:fp16
num-detected-classes=9
interval=0
gie-unique-id=1 
process-mode=1 # 1:primary 2:secondary 
network-type=0 # 0:detector 1: classifier
cluster-mode=2 # 2: NMS 
maintain-aspect-ratio=1
symmetric-padding=1
#force-implicit-batch-dim=1
#workspace-size=1000
parse-bbox-func-name=NvDsInferParseYolo
#parse-bbox-func-name=NvDsInferParseYoloCuda
custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so
engine-create-func-name=NvDsInferYoloCudaEngineGet

[class-attrs-all]
nms-iou-threshold=0.45
pre-cluster-threshold=0.25
topk=300

deepstream_app_config.txt:

[application]
enable-perf-measurement=1
perf-measurement-interval-sec=5

[tiled-display]
enable=0
rows=1
columns=1
width=1280
height=720
gpu-id=0
nvbuf-memory-type=0

[source0]
enable=1
type=3
uri=file:///opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4
num-sources=1
gpu-id=0
cudadec-memtype=0

[sink0]
enable=0
type=2
sync=0
gpu-id=0
nvbuf-memory-type=0

[sink1]
enable=1
type=3
#1=mp4 2=mkv
container=1
#1=h264 2=h265
codec=1
sync=0
#iframeinterval=10
bitrate=4000000
output-file=output_benchmark.mp4
source-id=0

[osd]
enable=1
gpu-id=0
border-width=5
text-size=15
text-color=1;1;1;1;
text-bg-color=0.3;0.3;0.3;1
font=Serif
show-clock=0
clock-x-offset=800
clock-y-offset=820
clock-text-size=12
clock-color=1;0;0;0
nvbuf-memory-type=0

[streammux]
gpu-id=0
live-source=0
batch-size=1
batched-push-timeout=40000
width=1920
height=1080
enable-padding=0
nvbuf-memory-type=0

[primary-gie]
enable=1
gpu-id=0
gie-unique-id=1
nvbuf-memory-type=0
config-file=config_infer_primary_yoloV5.txt

[tests]
file-loop=0
marcoslucianops commented 1 year ago

You are using the old files (the output layers are wrong). Please use the new files from this repo and regenerate the engine file (delete the engine file to recreate it).

zardadi commented 1 year ago

Thanks for the prompt reply. I cloned the repo one week ago on Jetosn Orin. I will clone it again and try to build the engine again if that helps. Do I need to regenerate the onnx file using the export_yoloV5.py file from DeepStream-Yolo/utils?

marcoslucianops commented 1 year ago

Do I need to regenerate the onnx file using the export_yoloV5.py file from DeepStream-Yolo/utils?

Yes

zardadi commented 1 year ago

Generating new onnx files solved the issue. I didn't need to update the repo on the Jetson as it was the lastest update. I needed to regenerate the onnx files as they were generated from the older commit of this repo. Thanks for your help @marcoslucianops