Production engineering • Arya Omnitalk

Twelve cameras, one GPU: the lock that ate 90% of our frame time

Moving our highway enforcement system from a small Jetson to a GPU server should have been the easy part. Instead, the first 12-camera run showed every camera spending most of its time waiting in line for the GPU. Here is what was wrong and how I fixed it.

Shubham Kulkarni
Shubham Kulkarni Software Engineer, AI/ML
Published November 2026
Hardware Jetson Orin Nano → RTX 5060 Ti

1. The starting point

VIDS (VIDES inside the company) is the highway enforcement and incident system I build at Arya Omnitalk. It reads the gantry cameras, detects and tracks every vehicle, reads its plate, measures its speed and checks it for violations and incidents. You can read the full picture in the VIDS case study.

It started on an NVIDIA Jetson Orin Nano at each gantry: 3 lane cameras for enforcement and 1 overview camera for incidents. One node runs 7 models: the vehicle detector, a plate detector, PaddleOCR, helmet and seatbelt models, RT-DETR for people, animals and debris, and a pothole model.

On a Jetson, GPU memory is shared with the CPU and there's only 8 GB of it. Two TensorRT contexts running at the same moment can run the device out of memory. So from day one, every GPU call went through one global lock: only one model runs at a time. On a single small device, that was the right call.

7Models on one node
126 msMedian detect + track, Orin Nano
125 msFrame budget at 8 fps processing
12Cameras on one RTX 5060 Ti

2. Moving to a GPU server

Some sites need many cameras in one place, and a Jetson per gantry stops making sense there. So we moved those sites to a GPU server with an RTX 5060 Ti. How many cameras one box can handle depends entirely on the hardware, so the only honest answer is to test it. The test: 12 cameras at 1080p, 25 fps, with every detector switched on.

The code was unchanged. Same pipeline, same global lock, just a much bigger GPU. I expected it to fly.

3. What the numbers said

It didn't fly. When I measured where each camera's frame time went, about 90% of it was spent waiting for the GPU lock. The GPU itself wasn't the problem. The queue in front of it was.

The cause was in how the overview cameras ran RT-DETR:

  • Every overview camera loaded its own RT-DETR engine, so 12 cameras meant about 12 engines.
  • Each camera ran its RT-DETR pass inside its own loop, holding the global lock while it ran.
  • RT-DETR is the heaviest model in the stack. While one camera ran it, every other camera's vehicle detection waited.
The real problem: a design that was correct for one small device (serialise everything) turned into a traffic jam on a big one. The lock was protecting us from something that no longer happened, and costing us almost all of our time.

4. The fix: an engine pool

Instead of one RT-DETR per camera, there is now a small shared pool of RT-DETR engines. By default it has one engine per gantry plus a spare, capped at 6. Cameras no longer run RT-DETR themselves. They hand a request to the pool and pick up the answer on a later frame.

01
Offer

At most a few times a second (4 by default), a camera offers its latest frame to the pool. If an old request from that camera is still waiting, the new one replaces it: newest wins.

02
Serve fairly

Free engines take the next waiting camera in round-robin order. Each camera has at most one request queued, so no camera can starve the others.

03
Drop stale work

A request older than 1 second is dropped and counted. On a highway, an answer about where a person was 2 seconds ago is worse than no answer.

04
Take

On a later frame, the camera picks up its result and updates its own tracker on its own thread. The vehicle loop never waits.

A simplified sketch of the camera side (the real code has more health checks):

Camera loop, pool mode (simplified)
handle = pool.register(camera_id, gantry_code)

while running:
    frame, ts = grabber.read_latest()
    vehicles = detect_and_track(frame)          # vehicle loop never waits on RT-DETR

    if presence_active and now() >= next_offer:
        handle.offer(Request(frame, ts, tiles, vehicle_snapshot(vehicles)))
        next_offer = now() + 1 / passes_per_sec

    result = handle.take()                      # None if nothing new yet
    if result:
        apply_result(presence_tracker, result)  # uses result.capture_ts, not now()
    elif handle.blind(now(), blind_sec=2.0):
        status = "failed"                       # freeze presence, never "road is empty"

When an engine misbehaves

  • Fails to load: retried after 30, 60, 120, then every 300 seconds. While nothing is loaded, cameras get an explicit "failed" result, not silence.
  • Hangs: if one prediction runs longer than 10 seconds, the worker is marked hung and a replacement starts.
  • Goes blind: if a camera gets no answer for 2 seconds, it reports failed and freezes its presence tracking. A detector outage must never look like an empty road.
  • Memory: the RT-DETR path holds at most 3 frame references per camera (request, in flight, result).

5. Getting time right

Making RT-DETR asynchronous creates a subtle problem: by the time a result arrives, the world has moved on. The incident rules care about time ("a person in the lane for N seconds"), so getting this wrong would quietly break them. Three rules keep it correct:

  1. Presence time is detection time. Dwell time and the presence clock use the capture time of the frame RT-DETR actually ran on, not the time the result arrived.
  2. Geometry uses the same moment. To tell a rider from a pedestrian, we compare the person with vehicle boxes. Those vehicle boxes come from a snapshot taken when the request was made, so a fast motorcycle that has moved 120 px since then doesn't turn its rider into a "pedestrian".
  3. Evidence comes from the result frame. The photo attached to a pedestrian or animal event is the frame the detection came from, so the box is always on the right spot.

A blind period never adds time to the presence clock when the camera recovers.

6. Targets and modes

Target (RTX host, 12 cameras)Why it matters
Vehicle loop at least 7 fps per camera (5th percentile) with an 8 fps capANPR and speed need steady frames
RT-DETR result age p95 under 800 msIncidents are confirmed on fresh data
A dead or hung engine never stops vehicle detection; recovery under 60 sEnforcement keeps running
Zero cross-camera track mix-ups and zero evidence frame mismatchesThe records are legal evidence

The pool is a mode, not a rewrite. inline stays the default for Jetson (same behaviour as before), pool is for GPU servers, and legacy keeps the old path for one release in case we need to roll back on site.

7. What I took away

  • Measure where the time goes before buying hardware. A faster GPU did nothing because the GPU wasn't the bottleneck.
  • Re-check old safety decisions when the platform changes. The global lock was right for an 8 GB Jetson and wrong for a GPU server.
  • Async work needs explicit timestamps. Once a result can arrive late, every rule has to know when the result is from.
  • Make failure loud. "Failed" is a real state. A detector outage must never quietly look like a clear road.
Note: VIDS is a proprietary Arya Omnitalk system. This post describes the design at a level that's fine to share in public. Sites, customers and code are confidential.