Deepstream not working

Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammy
Hardware Platform :** GPU RTX 3060, Intel i5 , 16GB Ram

balaji@balaji-B760M-H:~$ ls /usr/local | grep cuda
cuda
cuda-12
cuda-12.6
balaji@balaji-B760M-H:~$ deepstream-app --version
deepstream-app version 7.1.0
DeepStreamSDK 7.1.0
TensorRT version: 10.3.0
RTX3060
NVIDIA-SMI 580.95.05 Driver Version: 580.95.05 CUDA Version: 13.0

I try many solution but getting same wrong output error or wrong object detect.
please help me to fix this issue .

getting wrong output
please see video .

my code is

#!/usr/bin/env python3

import os

import sys

import subprocess

from shutil import which

# ================= USER CONFIG =================

BASE_PATH = “/home/balaji/Avinash/aiproject/deepstream”

# Make sure engine is built for TensorRT 10.3 / DeepStream 7.1

YOLO_ENGINE = “/home/balaji/Avinash/aiproject/yolov8n.engine”

#CUSTOM_LIB = “/home/balaji/Downloads/yolo_deepstream/deepstream_yolo/nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so”

CUSTOM_LIB = “/home/balaji/Avinash/aiproject/DeepStream-Yolo/nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so”

RTSP_URI = “rtsp://admin:admin%40123@192.168.0.195:554/cam/realmonitor?channel=2&subtype=0&protocols=tcp”

INPUT_WIDTH = 640

INPUT_HEIGHT = 640

NUM_CLASSES = 80

USE_DISPLAY = True # True: show output window; False: use headless fake sink

LOG_FILE = os.path.join(BASE_PATH, “deepstream_runner.log”)

# ==================== UTILS ====================

def log(msg):

print(msg)

with open(LOG_FILE, “a”) as f:

f.write(msg + “\n”)

def check_dependencies():

errors =

if not os.path.exists(YOLO_ENGINE):

errors.append(f"❌ YOLO engine not found: {YOLO_ENGINE}")

if not os.path.exists(CUSTOM_LIB):

errors.append(f"❌ Custom parser lib not found: {CUSTOM_LIB}")

if not which(“deepstream-app”):

errors.append(“❌ deepstream-app not found in PATH”)

return errors

# ==================== CONFIG GENERATORS ====================

def make_labels():

labels = [

“person”,“bicycle”,“car”,“motorcycle”,“airplane”,“bus”,“train”,“truck”,“boat”,

“traffic light”,“fire hydrant”,“stop sign”,“parking meter”,“bench”,“bird”,

“cat”,“dog”,“horse”,“sheep”,“cow”,“elephant”,“bear”,“zebra”,“giraffe”,

“backpack”,“umbrella”,“handbag”,“tie”,“suitcase”,“frisbee”,“skis”,“snowboard”,

“sports ball”,“kite”,“baseball bat”,“baseball glove”,“skateboard”,“surfboard”,

“tennis racket”,“bottle”,“wine glass”,“cup”,“fork”,“knife”,“spoon”,“bowl”,

“banana”,“apple”,“sandwich”,“orange”,“broccoli”,“carrot”,“hot dog”,“pizza”,

“donut”,“cake”,“chair”,“couch”,“potted plant”,“bed”,“dining table”,“toilet”,

“tv”,“laptop”,“mouse”,“remote”,“keyboard”,“cell phone”,“microwave”,“oven”,

“toaster”,“sink”,“refrigerator”,“book”,“clock”,“vase”,“scissors”,“teddy bear”,

“hair drier”,“toothbrush”

\]

os.makedirs(BASE_PATH, exist_ok=True)

path = os.path.join(BASE_PATH, “labels.txt”)

with open(path, “w”) as f:

f.write(“\n”.join(labels))

log(f"✓ Labels created: {path}")

return path

def make_infer_config(labels_path):

cfg = f"“”[property]

gpu-id=0

gie-unique-id=1

model-engine-file={YOLO_ENGINE}

labelfile-path={labels_path}

batch-size=1

network-type=0

num-detected-classes={NUM_CLASSES}

process-mode=1

interval=0

custom-lib-path={CUSTOM_LIB}

parse-bbox-func-name=NvDsInferParseYoloCuda

cluster-mode=4

maintain-aspect-ratio=1

symmetric-padding=1

network-mode=2

“”"

path = os.path.join(BASE_PATH, “config_infer_primary.txt”)

with open(path, “w”) as f:

f.write(cfg.strip())

log(f"✓ Inference config created: {path}")

return path

def make_app_config(infer_cfg):

sink_type = 2 if USE_DISPLAY else 5 # 2=overlay window, 5=fake sink

cfg = f"“”[application]

enable-perf-measurement=1

perf-measurement-interval-sec=5

[source0]

enable=1

type=4

uri={RTSP_URI}

latency=300

cudadec-memtype=0

[streammux]

gpu-id=0

batch-size=1

width={INPUT_WIDTH}

height={INPUT_HEIGHT}

live-source=1

batched-push-timeout=40000

nvbuf-memory-type=0

[primary-gie]

enable=1

gpu-id=0

config-file={infer_cfg}

[osd]

enable=1

gpu-id=0

border-width=2

text-size=18

display-text=1

text-bg-color=0;0;0;0.6

text-color=1;1;1;1

clock-text-size=16

process-mode=0

[sink0]

enable=1

type={sink_type}

sync=0

“”"

path = os.path.join(BASE_PATH, “deepstream_app_config.txt”)

with open(path, “w”) as f:

f.write(cfg.strip())

log(f"✓ App config created: {path}")

return path

# ==================== RUNNER ====================

def run_deepstream(app_cfg):

log(“\n🚀 Starting DeepStream…”)

cmd = [“deepstream-app”, “-c”, app_cfg]

log(f"Command: {’ '.join(cmd)}")

# Use subprocess to capture stdout/stderr

try:

with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) as p:

for line in p.stdout:

log(line.strip())

p.wait()

log(f"DeepStream exited with code {p.returncode}")

except Exception as e:

log(f"❌ Failed to run DeepStream: {e}")

# ==================== MAIN ====================

def main():

log(“\n🔹 DeepStream YOLO Runner 🔹\n”)

errors = check_dependencies()

if errors:

for e in errors:

log(e)

return 1

labels = make_labels()

infer_cfg = make_infer_config(labels)

app_cfg = make_app_config(infer_cfg)

run_deepstream(app_cfg)

return 0

if _name_ == “_main_”:

sys.exit(main())

Please refer to the compatibility table, DeepStream 7.1 requires driver R560.35.03 if using RTX GPU.
Please refer to the ready-made yolov8 sample yolo_deepstream and YOLOv8-DeepStream-TRT-Jetson.

i try install this R560.35.03 version manually but not install.

my system only support this versions .

Command ‘nvidia-smi’ not found, but can be installed with:
sudo apt install nvidia-utils-390 # version 390.157-0ubuntu0.22.04.2, or
sudo apt install nvidia-utils-418-server # version 418.226.00-0ubuntu5~0.22.04.1
sudo apt install nvidia-utils-450-server # version 450.248.02-0ubuntu0.22.04.1
sudo apt install nvidia-utils-470 # version 470.256.02-0ubuntu0.22.04.1
sudo apt install nvidia-utils-470-server # version 470.256.02-0ubuntu0.22.04.1
sudo apt install nvidia-utils-535 # version 535.274.02-0ubuntu0.22.04.1
sudo apt install nvidia-utils-535-server # version 535.274.02-0ubuntu0.22.04.1
sudo apt install nvidia-utils-550-server # version 550.163.01-0ubuntu0.22.04.1
sudo apt install nvidia-utils-570 # version 570.195.03-0ubuntu0.22.04.1
sudo apt install nvidia-utils-545 # version 545.29.06-0ubuntu0.22.04.2
sudo apt install nvidia-utils-565-server # version 565.57.01-0ubuntu0.22.04.4
sudo apt install nvidia-utils-570-server # version 570.195.03-0ubuntu0.22.04.3
sudo apt install nvidia-utils-580 # version 580.95.05-0ubuntu0.22.04.2
sudo apt install nvidia-utils-580-server # version 580.95.05-0ubuntu0.22.04.3
sudo apt install nvidia-utils-510 # version 510.60.02-0ubuntu1
sudo apt install nvidia-utils-510-server # version 510.47.03-0ubuntu3

any other way to fix this issue?

When i use deep stream 8.0 same issue getting . wrong object detect continue.

Distributor ID: Ubuntu
Description: Ubuntu 24.04.3 LTS
Release: 24.04
NVIDIA-SMI 570.195.03 Driver Version: 570.195.03 CUDA Version: 12.8
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2025 NVIDIA Corporation
Built on Fri_Feb_21_20:23:50_PST_2025
Cuda compilation tools, release 12.8, V12.8.93
Build cuda_12.8.r12.8/compiler.35583870_0
hi tensorrt 10.9.0.34-1+cuda12.8 amd64 Meta package for TensorRT
deepstream-app version 8.0.0
DeepStreamSDK 8.0.0
st-launch-1.0 version 1.24.2
GStreamer 1.24.2
cuDNN version: 9.17.0

Is the model your retrained model? Have you verified the model with other tools? First Please please read nvinfer doc to check if all preprocessing settings are correct.

i used yolov8n.pt pretraind model with 80 class.
when i run yolov8n.pt direct in python it working fine but when i use deepstream at time not working.
you can see above code all peramters

Please refer to my first comment, which includes some yolov8 samples. In your code, “net-scale-factor” configuration is not found. Please compare your code with the sample to check which configurations are still missing.

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks.