How to access cuda array on gpu in Python

I am working with Python 3.6 and DeepStream 5.1.
I would like to decode an Rtsp video stream and to access the decoded frames on the gpu using libraries such as pycuda or cupy (other libraries might work too). I don’t want to access numpy array because I don’t want to copy the data to the cpu.
It is my understanding that nveglglessink is a sink stored on the gpu. How can I extract cuda arrays from it?

import sys
import pyds
import math
import threading
import gi
gi.require_version("Gst", "1.0")
from gi.repository import GObject, Gst, GLib



rtsp_url = "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"

# Standard GStreamer initialization
class MyPipeline:

    def __init__(self):
        GObject.threads_init()
        Gst.init(None)

        self.pipeline = Gst.Pipeline()

        pipeline_command = f"""
            rtspsrc location={rtsp_url} latency=250 drop-on-latency=true ! 
            rtph264depay ! 
            h264parse ! 
            nvv4l2decoder ! 
            nvvideoconvert ! 
            video/x-raw,format=RGBA !
            videoconvert !
            nveglglessink
        """
        self.pipeline = Gst.parse_launch(pipeline_command)

    def loop(self):
        print("Start pipeline")
        self.pipeline.set_state(Gst.State.PLAYING)
        loop = GObject.MainLoop()

        try:
            loop.run()
        except:
            loop.quit()

    def start(self):
        thread = threading.Thread(target=self.loop)
        thread.start()


my_pipeline = MyPipeline()
my_pipeline.start()

Which platform you are running on?

Ubuntu 18.04, TensorRT 7.1.2.6, Python 3.6, Deepstream 5.1, CuDNN 8.0

I am also using NVIDIA GPUs such as GTX 2060 and T4

Hello @amycao , I just wanted to ask you if you think this can be done, and if you can point me to any example. Thank you!

UPDATE: I can update to Deepstream 6.0

Sorry for the late.
You can refer to this topic about this.
How to access the image array from buffer in GPU buffer? - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums

Please move to 6.0 firstly.
We added a binding for this but it only supports x86 right now: get_nvds_buf_surface_gpu().
No sample in DS but MONAI project uses this - refer to that as a sample MONAIStream/transform_cupy.py at 0af89d4381c58a165871bfbfe14b3dcb9e85fbf3 · Project-MONAI/MONAIStream · GitHub