Hello,
I have been using YOLO inferencing for about a year to analyze 24 camera feeds. I have one dedicated computer for this purpose, a new ASUS desktop that has powerful specs. The inference runs about every 1 second for each of the 24 camera feeds, on yolo26x.pt model. Each of the cameras are associated to any of 17 zones, and each zone is a different process with its own yolo model loaded. each zone process then hands off the yolo model to worker threads that then do the inferencing on the camera feeds. the camera feeds are pulled from a hikvision system, from its picture snapshots and not from RTSP, because the RTSP is too heavy. These picture snapshots are then provided to the yolo inferencing every second. After some time though, the entire computer hard freezes. And I have to manually shut down the computer and turn on again. The computer does not freeze if I don’t do yolo inferencing. But when I do the yolo inferencing, after some time, it freezes. I’ve noticed that its at around the 1-2 hour mark that it freezes. These are my computer specs and the code in reference:
ASUS ROG G700TF-XS987 - Ultra 9-285K - RTX 5080
ADVANCED LIQUID COOLING
Video Card
NVIDIA® GeForce RTX™ 5080 PRIME w/ 16 GB GDDR7
Processor
Intel® Core Arrow Lake Ultra 9-285K 24 Core - 24 Thread Processor, 3.2 GHz (Max Turbo Frequency 5.7 GHz), 36 MB Smart Cache
Thermal Interface Materials
Stock TIM - Stock thermal compound and thermal pads
Power Supply
ASUS 850W power supply (80+ Gold, peak 900W)
Memory
HIDevolution Approved Standard 64 GB Dual Channel DDR5 6000MHz (2 x 32 GB) - Speeds subject to system capability - installed by HIDevolution
_____________________
RELEVANT CODE (SIMPLIFIED)
import threading
import time
import multiprocessing
import yaml
from ultralytics import YOLO
import torch
import cv2
import logging
import numpy as np
from multiprocessing import freeze_support
from multiprocessing import Manager
def load_camera_config():
try:
with open("configs.yaml", "r") as f:
return yaml.safe_load(f)
except Exception as e:
return {}
#SNAPSHOTS AND QUEUE ARE POPULATED ELSEHWERE
snapshots = None
queued_zones = None
sound_queue = None
manager = None
config = load_camera_config()
cameras_config = config["cameras"]
zones_config = config["zones"]
def poll_armed_zones_from_ha(previously_armed_zones=None):
#CODE TO PULL ARMED ZONES, 17 ZONES TOTAL
return {}
def monitor_zone_process(zone, queued_zones, sound_queue, snapshots):
logging.getLogger("ultralytics").setLevel(logging.ERROR)
local_model = YOLO("yolo26x.pt")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
local_model.model.to(device)
zone_name = zone["name"]
camera_keys = zone.get("cameras", [])
cam_procs = {}
while True:
for camera_key in camera_keys:
if camera_key not in cam_procs or not cam_procs[camera_key].is_alive():
cam_proc = threading.Thread(
target=monitor_camera_using_still_image,
args=(camera_key, zone_name, local_model, queued_zones, sound_queue, snapshots),
daemon=True
)
cam_proc.start()
cam_procs[camera_key] = cam_proc
def monitor_camera_using_still_image(camera_key, zone_name, local_model, snapshots):
while True:
image_bytes = snapshots.get(camera_key)
try:
np_arr = np.frombuffer(image_bytes, dtype=np.uint8)
frame = cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
except Exception as decode_err:
time.sleep(0.2)
continue
results = local_model(frame)
detected = False
for x1, y1, x2, y2, conf, cls in results[0].boxes.data.tolist():
if int(cls) != 0:
continue
detected = True
if detected:
sound_queue.put({"zone": zone_name, "camera": camera_key})
queued_zones[zone_name] = True
time.sleep(1)
def main_loop():
monitor_processes = {}
while True:
armed_zones = poll_armed_zones_from_ha(previously_armed_zones)
previously_armed_zones = set(armed_zones)
for zone in zones_config:
zone_name = zone["name"]
if zone_name in armed_zones:
if zone_name not in monitor_processes:
proc = multiprocessing.Process(target=monitor_zone_process, args=(zone, queued_zones, sound_queue, snapshots), daemon=True)
monitor_processes[zone_name] = (proc)
proc.start()
time.sleep(1)
if __name__ == '__main__':
freeze_support()
manager = Manager()
sound_queue = manager.Queue()
queued_zones = manager.dict()
while True:
main_loop()