Fails to Generate Engine and fails perform Segmenation using deepstream-segmentation

i am try to run deepstream-segmentation on my docker container where i have deepstream sdk 7.0 and python 3.10 and tensorrt TensorRT-8.6.1.6 but it fails to generate engine .i TRIED WITH MODEL uff-file=../../../../samples/models/Segmentation/semantic/unetres18_v4_pruned0.65_800_data.uff
but it fails to generate engine model-engine-file=../../../../samples/models/Segmentation/semantic/unetres18_v4_pruned0.65_800_data.uff_b1_gpu0_fp32.engine I am using this config for engine generation [property]
gpu-id=0
net-scale-factor=1.0
model-color-format=0
uff-file=../../../../samples/models/Segmentation/semantic/unetres18_v4_pruned0.65_800_data.uff
model-engine-file=../../../../samples/models/Segmentation/semantic/unetres18_v4_pruned0.65_800_data.uff_b1_gpu0_fp32.engine
infer-dims=3;512;512
uff-input-order=0
uff-input-blob-name=data
batch-size=2

0=FP32, 1=INT8, 2=FP16 mode

network-mode=0
num-detected-classes=4
interval=0
gie-unique-id=1
network-type=2
output-blob-names=final_conv/BiasAdd
segmentation-threshold=0.0
#parse-bbox-func-name=NvDsInferParseCustomSSD
#custom-lib-path=nvdsinfer_custom_impl_ssd/libnvdsinfer_custom_impl_ssd.so
#scaling-filter=0
#scaling-compute-hw=0

[class-attrs-all]
roi-top-offset=0
roi-bottom-offset=0
detected-min-w=0
detected-min-h=0
detected-max-w=0
detected-max-h=0
and using this script for pipeline
import sys

sys.path.append(‘../’)
import gi
import math

gi.require_version(‘Gst’, ‘1.0’)
from gi.repository import GLib, Gst
from common.platform_info import PlatformInfo
from common.bus_call import bus_call
import cv2
import pyds
import numpy as np
import os.path
from os import path

MAX_DISPLAY_LEN = 64
MUXER_OUTPUT_WIDTH = 1920
MUXER_OUTPUT_HEIGHT = 1080
MUXER_BATCH_TIMEOUT_USEC = 33000
TILED_OUTPUT_WIDTH = 1280
TILED_OUTPUT_HEIGHT = 720
COLORS = [[128, 128, 64], [0, 0, 128], [0, 128, 128], [128, 0, 0],
[128, 0, 128], [128, 128, 0], [0, 128, 0], [0, 0, 64],
[0, 0, 192], [0, 128, 64], [0, 128, 192], [128, 0, 64],
[128, 0, 192], [128, 128, 128]]

def map_mask_as_display_bgr(mask):
“”" Assigning multiple colors as image output using the information
contained in mask. (BGR is opencv standard.)
“”"
# getting a list of available classes
m_list = list(set(mask.flatten()))

shp = mask.shape
bgr = np.zeros((shp[0], shp[1], 3))
for idx in m_list:
    bgr[mask == idx] = COLORS[idx]
return bgr

def seg_src_pad_buffer_probe(pad, info, u_data):
gst_buffer = info.get_buffer()
if not gst_buffer:
print("Unable to get GstBuffer ")
return

# Retrieve batch metadata from the gst_buffer
# Note that pyds.gst_buffer_get_nvds_batch_meta() expects the
# C address of gst_buffer as input, which is obtained with hash(gst_buffer)
batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))
l_frame = batch_meta.frame_meta_list
while l_frame is not None:
    try:
        # Note that l_frame.data needs a cast to pyds.NvDsFrameMeta
        # The casting is done by pyds.NvDsFrameMeta.cast()
        # The casting also keeps ownership of the underlying memory
        # in the C code, so the Python garbage collector will leave
        # it alone.
        frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
    except StopIteration:
        break
    frame_number = frame_meta.frame_num
    l_user = frame_meta.frame_user_meta_list
    while l_user is not None:
        try:
            # Note that l_user.data needs a cast to pyds.NvDsUserMeta
            # The casting is done by pyds.NvDsUserMeta.cast()
            # The casting also keeps ownership of the underlying memory
            # in the C code, so the Python garbage collector will leave
            # it alone.
            seg_user_meta = pyds.NvDsUserMeta.cast(l_user.data)
        except StopIteration:
            break
        if seg_user_meta and seg_user_meta.base_meta.meta_type == \
                pyds.NVDSINFER_SEGMENTATION_META:
            try:
                # Note that seg_user_meta.user_meta_data needs a cast to
                # pyds.NvDsInferSegmentationMeta
                # The casting is done by pyds.NvDsInferSegmentationMeta.cast()
                # The casting also keeps ownership of the underlying memory
                # in the C code, so the Python garbage collector will leave
                # it alone.
                segmeta = pyds.NvDsInferSegmentationMeta.cast(seg_user_meta.user_meta_data)
            except StopIteration:
                break
            # Retrieve mask data in the numpy format from segmeta
            # Note that pyds.get_segmentation_masks() expects object of
            # type NvDsInferSegmentationMeta
            masks = pyds.get_segmentation_masks(segmeta)
            masks = np.array(masks, copy=True, order='C')
            # map the obtained masks to colors of 2 classes.
            frame_image = map_mask_as_display_bgr(masks)
            cv2.imwrite(folder_name + "/" + str(frame_number) + ".jpg", frame_image)
        try:
            l_user = l_user.next
        except StopIteration:
            break
    try:
        l_frame = l_frame.next
    except StopIteration:
        break
return Gst.PadProbeReturn.OK

def main(args):
# Check input arguments
if len(args) != 4:
sys.stderr.write("usage: %s config_file <jpeg/mjpeg file> "
“\n” % args[0])
sys.exit(1)

global folder_name
folder_name = args[-1]
if path.exists(folder_name):
    sys.stderr.write("The output folder %s already exists. "
                     "Please remove it first.\n" % folder_name)
    sys.exit(1)
os.mkdir(folder_name)

config_file = args[1]
num_sources = len(args) - 3
# Standard GStreamer initialization
platform_info = PlatformInfo()
Gst.init(None)

# Create gstreamer elements
# Create Pipeline element that will form a connection of other elements
print("Creating Pipeline \n ")
pipeline = Gst.Pipeline()

if not pipeline:
    sys.stderr.write(" Unable to create Pipeline \n")

# Source element for reading from the file
print("Creating Source \n ")
source = Gst.ElementFactory.make("filesrc", "file-source")
if not source:
    sys.stderr.write(" Unable to create Source \n")

# Since the data format in the input file is jpeg,
# we need a jpegparser
print("Creating jpegParser \n")
jpegparser = Gst.ElementFactory.make("jpegparse", "jpeg-parser")
if not jpegparser:
    sys.stderr.write("Unable to create jpegparser \n")

# Use nvdec for hardware accelerated decode on GPU
print("Creating Decoder \n")
decoder = Gst.ElementFactory.make("nvv4l2decoder", "nvv4l2-decoder")
if not decoder:
    sys.stderr.write(" Unable to create Nvv4l2 Decoder \n")

# Create nvstreammux instance to form batches from one or more sources.
streammux = Gst.ElementFactory.make("nvstreammux", "Stream-muxer")
if not streammux:
    sys.stderr.write(" Unable to create NvStreamMux \n")

# Create nvvideoconvert to convert jpegdecoder's I420 to NV12
nvvidconv = Gst.ElementFactory.make("nvvideoconvert", "nvvideconvert")
if not nvvidconv:
    sys.stderr.write(" Unable to create nvvideoconvert \n")

# Create segmentation for primary inference
seg = Gst.ElementFactory.make("nvinfer", "primary-nvinference-engine")
if not seg:
    sys.stderr.write("Unable to create primary inferene\n")

# Create nvsegvisual for visualizing segmentation
nvsegvisual = Gst.ElementFactory.make("nvsegvisual", "nvsegvisual")
if not nvsegvisual:
    sys.stderr.write("Unable to create nvsegvisual\n")

if platform_info.is_integrated_gpu():
    print("Creating nv3dsink \n")
    sink = Gst.ElementFactory.make("nv3dsink", "nv3d-sink")
    if not sink:
        sys.stderr.write(" Unable to create nv3dsink \n")
else:
    if platform_info.is_platform_aarch64():
        print("Creating nv3dsink \n")
        sink = Gst.ElementFactory.make("nv3dsink", "nv3d-sink")
    else:
        print("Creating EGLSink \n")
        sink = Gst.ElementFactory.make("nveglglessink", "nvvideo-renderer")
    if not sink:
        sys.stderr.write(" Unable to create egl sink \n")

print("Playing file %s " % args[2])
source.set_property('location', args[2])
if platform_info.is_integrated_gpu() and ("mjpeg" in args[2] or "mjpg" in args[2]):
    print ("setting decoder mjpeg property")
    decoder.set_property('mjpeg', 1)
streammux.set_property('width', 1920)
streammux.set_property('height', 1080)
streammux.set_property('batch-size', 1)
streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC)
seg.set_property('config-file-path', config_file)
pgie_batch_size = seg.get_property("batch-size")
if pgie_batch_size != num_sources:
    print("WARNING: Overriding infer-config batch-size", pgie_batch_size,
          " with number of sources ", num_sources,
          " \n")
    seg.set_property("batch-size", num_sources)
nvsegvisual.set_property('batch-size', num_sources)
nvsegvisual.set_property('width', 512)
nvsegvisual.set_property('height', 512)
sink.set_property("qos", 0)
print("Adding elements to Pipeline \n")
pipeline.add(source)
pipeline.add(jpegparser)
pipeline.add(decoder)
pipeline.add(streammux)
pipeline.add(nvvidconv)
pipeline.add(seg)
pipeline.add(nvsegvisual)
pipeline.add(sink)

# we link the elements together
# file-source -> jpeg-parser -> nvv4l2-decoder ->
# nvinfer -> nvsegvisual -> sink
print("Linking elements in the Pipeline \n")
source.link(jpegparser)
jpegparser.link(decoder)

sinkpad = streammux.request_pad_simple("sink_0")
if not sinkpad:
    sys.stderr.write(" Unable to get the sink pad of streammux \n")
srcpad = decoder.get_static_pad("src")
if not srcpad:
    sys.stderr.write(" Unable to get source pad of decoder \n")
srcpad.link(sinkpad)
streammux.link(nvvidconv)
nvvidconv.link(seg)
seg.link(nvsegvisual)
nvsegvisual.link(sink)
# create an event loop and feed gstreamer bus mesages to it
loop = GLib.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", bus_call, loop)

# Lets add probe to get informed of the meta data generated, we add probe to
# the src pad of the inference element
seg_src_pad = seg.get_static_pad("src")
if not seg_src_pad:
    sys.stderr.write(" Unable to get src pad \n")
else:
    seg_src_pad.add_probe(Gst.PadProbeType.BUFFER, seg_src_pad_buffer_probe, 0)

# List the sources
print("Now playing...")
for i, source in enumerate(args[1:-1]):
    if i != 0:
        print(i, ": ", source)

print("Starting pipeline \n")
# start play back and listed to events
pipeline.set_state(Gst.State.PLAYING)
try:
    loop.run()
except:
    pass
# cleanup
pipeline.set_state(Gst.State.NULL)

if name == ‘main’:
sys.exit(main(sys.argv))
…It taking too much time to generate engine and fails to perform segmentation by running script python3.10 deepstream_segmentation.pdstest_segmentation_config_semantic.txt rsb1_entry_crop.mp4 output_frames/
please provide solution..I have system A4000 ,20 gpu system and where i am CUDA Version: 12.8 Driver Version: 570.133.07

It might be due to an incompatible driver version. You can refer to our dGPU model Platform and OS Compatibility to install the compatible version.

I’m running on a workstation equipped with an NVIDIA RTX A4000 GPU and 20 CPU cores, under Ubuntu 22.04.3 LTS:
DeepStream SDK:7.0.0
NVIDIA Driver: 570.133.07 (CUDA Runtime 12.8)
CUDA Toolkit (nvcc):11.5.119
TensorRT: 8.6.1
GCC:11.4.0
GStreamer:1.20.3…PLEASE PROVIDE COMPATIBLE ISSUE AND SOLUTION

I have attached the compatible software for each version of the DeepStream in the previous link. Please pay attention to the data in the DS7.0 column.

**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**