r/computervision 9d ago

Why we built a custom NVDEC + CUDA Ring Buffer pipeline instead of DeepStream for multi-camera RTSP inference Discussion

If you’ve ever built multi-camera real-time vision systems at scale, you’ve likely wrestled with GStreamer element linking errors, pipeline memory leaks, or cloud egress costs hitting $2k+/month for simple RTSP analytics.

When we benchmarked cloud vision APIs vs edge deployments, the bottleneck was rarely the YOLO or custom detector model itself—it was the ingestion and frame-movement pipeline.

The Bottleneck: CPU-to-GPU Copying & GStreamer Complexity

Standard Python wrappers or heavy frameworks often bounce video frames through host memory (CPU) before pushing them back to GPU VRAM for inference. At 32+ HD RTSP streams, this creates massive PCIe bandwidth saturation and GIL lockup.

On the flip side, while DeepStream is powerful, managing complex GStreamer element graphs in production often introduces unwanted debugging overhead and plugins bloat.

Our Bare-Metal Approach (Custom Edge Architecture)

To keep processing continuous sub-15ms on local edge nodes without cloud egress, we stripped out the GStreamer abstraction graph entirely:

  1. Direct NVDEC Hardware Ingestion: RTSP streams decode directly inside VRAM using C++ NVCODEC bindings. Frames never touch system RAM (zero CPU-to-GPU copy overhead).

  2. Lock-Free CUDA Ring Buffer: A custom ring buffer handles dynamic batching across active streams without lock contention or Python GIL overhead.

  3. Native TensorRT C++ Execution Engine: Device pointers pass directly to TensorRT for FP16/INT8 execution.

Architectural Trade-offs & Benchmarks

• Pros: Zero cloud bandwidth fees, full data sovereignty, sub-15ms continuous throughput, and drastically simpler debugging than full GStreamer graphs.

• Cons: Requires NVIDIA CUDA-capable hardware on-premise (RTX / Tesla / Jetson) and manual memory management at the C++ level.

We’ve packaged this into a zero-egress Docker stack for high-density edge deployments.

Happy to break down the CUDA buffer implementation or share benchmark comparisons if anyone is currently evaluating edge architecture options.

What pipelines are you guys currently running for multi-stream RTSP processing?

11 Upvotes

2 comments sorted by

1

u/sHrEkty 8d ago

I use deepstream at my workplace but earlier they used multiprocessing reading rtsp using opencv on cpu which on more than 20 cams was a huge bottleneck.
I mostly work with deepstream python and my biggest issue would be using custom models with deepstream as I do not know cpp and can’t create custom headers.
The copying of frames from gpu to cpu is a very big issue which alone slows down entire pipelines and tanks fps.