NVOF cannot free memory for frames copied to GPU memory

  • Hardware Platform (Jetson / GPU) - ZOTAC GeForce RTX 2060 SUPER
  • DeepStream Version - v5.0.1
  • JetPack Version (valid for Jetson only) - N/A
  • TensorRT Version - N/A
  • Issue Type (questions, new requirements, bugs) - Bug
  • How to reproduce the issue?
    This issue occurs whenever we are dealing with frames that are copied to GPU memory via nvvideoconvert with regards to the nvof element. Two examples of this issue are shown below:
  1. gst-launch-1.0 nvstreammux name=streammux width=800 height=600 batch-size=1 videotestsrc num-buffers=10 ! video/x-raw,framerate=15/1,width=800,height=600 ! nvvideoconvert nvbuf-memory-type=3 ! "video/x-raw(memory:NVMM)" ! streammux.sink_0 streammux.src ! nvof ! fakesink
    
    Setting pipeline to PAUSED ...
    Device Number: 0
    Device name: GeForce RTX 2060 SUPER
    Device Version 7.5
    Device Supports Optical Flow Functionality
    Pipeline is PREROLLING ...
    gst_ds_optical_flow_set_caps: Creating OpticalFlow Context for Source = 0
    libnvds_opticalflow_dgpu: Setting GPU_ID = 0
    Pipeline is PREROLLED ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    Got EOS from element "pipeline0".
    Execution ended after 0:00:00.011969125
    Setting pipeline to PAUSED ...
    Setting pipeline to READY ...
    ds_optical_flow_destroy_oflib_ctx: Destroying oflib ctx 0x7efddc002000
    Cuda failure: status=1
    nvbufsurface: Error(-1) in releasing cuda memory
    Cuda failure: status=1
    nvbufsurface: Error(-1) in releasing cuda memory
    Cuda failure: status=1
    nvbufsurface: Error(-1) in releasing cuda memory
    Cuda failure: status=1
    nvbufsurface: Error(-1) in releasing cuda memory
    Setting pipeline to NULL ...
    Freeing pipeline ...
    
  2. gst-launch-1.0 videotestsrc num-buffers=900 ! video/x-raw,framerate=15/1,width=800,height=600 ! x264enc ! video/x-h264,profile=main ! h264parse ! mp4mux ! filesink location=/tmp/test.mp4
        
    gst-launch-1.0 nvstreammux name=streammux width=800 height=600 batch-size=1 filesrc location=/tmp/test.mp4 ! qtdemux ! h264parse ! avdec_h264 ! videoconvert ! video/x-raw,format=NV12 ! nvvideoconvert nvbuf-memory-type=3 ! "video/x-raw(memory:NVMM)" ! streammux.sink_0 streammux.src ! nvof ! fakesink
    
    Setting pipeline to PAUSED ...
    Device Number: 0
    Device name: GeForce RTX 2060 SUPER
    Device Version 7.5
    Device Supports Optical Flow Functionality
    Pipeline is PREROLLING ...
    Redistribute latency...
    gst_ds_optical_flow_set_caps: Creating OpticalFlow Context for Source = 0
    libnvds_opticalflow_dgpu: Setting GPU_ID = 0
    Redistribute latency...
    Pipeline is PREROLLED ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    Got EOS from element "pipeline0".
    Execution ended after 0:00:01.230870105
    Setting pipeline to PAUSED ...
    Setting pipeline to READY ...
    ds_optical_flow_destroy_oflib_ctx: Destroying oflib ctx 0x7f7e8c01ab00
    Cuda failure: status=1
    nvbufsurface: Error(-1) in releasing cuda memory
    Cuda failure: status=1
    nvbufsurface: Error(-1) in releasing cuda memory
    Cuda failure: status=1
    nvbufsurface: Error(-1) in releasing cuda memory
    Cuda failure: status=1
    nvbufsurface: Error(-1) in releasing cuda memory
    Setting pipeline to NULL ...
    Freeing pipeline ...
    

This is a problem for us, as it restricts us to only using the nvv4l2decoder element, as nvof has no issues with GPU buffers allocated with that element. As a result, we cannot use software decoding for H264 or other formats; limiting us to whatever formats nvv4l2decoder supports.

We can reproduce the error. Will tracking this issue.