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://"

# Standard GStreamer initialization
class MyPipeline:

    def __init__(self):

        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 !
        self.pipeline = Gst.parse_launch(pipeline_command)

    def loop(self):
        print("Start pipeline")
        loop = GObject.MainLoop()


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

my_pipeline = MyPipeline()

Which platform you are running on?

Ubuntu 18.04, TensorRT, 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/ at 0af89d4381c58a165871bfbfe14b3dcb9e85fbf3 · Project-MONAI/MONAIStream · GitHub

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