Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 173 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# DeepStream Mono-Repo — Build & Run Guide

## Prerequisites

### NVIDIA Compute Stack

Before building from source, the NVIDIA compute stack must be installed on the host. Required versions:

| Platform | OS | Driver | CUDA | cuDNN | TensorRT |
|---|---|---|---|---|---|
| x86 dGPU | Ubuntu 24.04 | 590.48.01+ | 13.1 | 9.18.0 | 10.14.x |
| Jetson (aarch64) | JetPack 7.1 GA | — (bundled) | 13.0 | 9.12.0 | 10.13.x |
| SBSA / DGX Spark | Ubuntu 24.04 | 590.48.01+ | 13.0 | 9.18.0 | 10.14.x |

For installation instructions, refer to the official [DeepStream SDK Installation Guide](https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Installation.html).

> **Docker users:** NVIDIA NGC provides pre-built DeepStream 9.0 containers with the full compute stack pre-installed. If using a container, skip this section and proceed to Git LFS setup below.

---

### Clone the Repository

```bash
sudo apt-get install cmake
```

### x86 (dGPU)

1. Download the DS 9.0 public released Debian package, install it, and add the
DeepStream lib directory to `LD_LIBRARY_PATH` so the runtime can locate the
shared libraries:
```bash
sudo apt install ./deepstream-9.0_9.0.0-1_amd64.deb
sudo /opt/nvidia/deepstream/deepstream-9.0/install.sh
export LD_LIBRARY_PATH=/opt/nvidia/deepstream/deepstream-9.0/lib:$LD_LIBRARY_PATH
```
Append the `export` line to `~/.bashrc` to persist it across shells.

2. Install system dependencies:
```bash
sudo apt install \
libssl3 \
libssl-dev \
libcurl4-openssl-dev \
libgles2-mesa-dev \
libgstreamer1.0-0 \
gstreamer1.0-tools \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
libgstreamer-plugins-base1.0-dev \
libgstrtspserver-1.0-0 \
libjansson4 \
libjsoncpp-dev \
libyaml-cpp-dev \
libmosquitto1
```

See also the [DeepStream Installation Guide — Install Prerequisite Packages](https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Installation.html#id2).

### aarch64 (Jetson)

1. Download the DS 9.0 public released Debian package, install it, and add the
DeepStream lib directory to `LD_LIBRARY_PATH` so the runtime can locate the
shared libraries:
```bash
sudo apt install ./deepstream-9.0_9.0.0-1_arm64.deb
sudo /opt/nvidia/deepstream/deepstream-9.0/install.sh
export LD_LIBRARY_PATH=/opt/nvidia/deepstream/deepstream-9.0/lib:$LD_LIBRARY_PATH
```
Append the `export` line to `~/.bashrc` to persist it across shells.

2. Install system dependencies:
```bash
sudo apt install \
libssl3 \
libssl-dev \
libcurl4-openssl-dev \
libgstreamer1.0-0 \
gstreamer1.0-tools \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
libgstreamer-plugins-base1.0-dev \
libgstrtspserver-1.0-0 \
libjansson4 \
libjsoncpp-dev \
libyaml-cpp-dev \
libmosquitto1
```

See also the [DeepStream Installation Guide — Install Prerequisite Packages](https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Installation.html#install-prerequisite-packages).

### SBSA / DGX Spark (Server Base System Architecture)

SBSA and DGX Spark share the same code path. There is no DS tar/deb package for this platform. The validated environment is the SBSA Docker image.
Build and validation must be done **inside the Docker container**.

1. Start the SBSA Docker container (with GPU access):
```bash
docker run -it --gpus all <sbsa-docker-image> bash
```

2. Install build prerequisites inside the container:
```bash
apt-get update && apt-get install -y git cmake make build-essential
```

3. `sudo` is not present in the container by default. Create a passthrough stub since you are already root:
```bash
printf '#!/bin/sh\nexec env "$@"\n' > /usr/local/bin/sudo && chmod +x /usr/local/bin/sudo
```

4. Clone the mono-repo:
```bash
git clone https://gitlab-master.nvidia.com/DeepStreamSDK/deepstream -b main deepstream
cd deepstream
```

---

## Build and Install

`build.sh` auto-detects the host platform and:
- On SBSA / DGX Spark: passes `AARCH64_IS_SBSA=1` to all Makefiles (both `aarch64` and `sbsa` report `uname -m` as `aarch64`; SBSA is identified by the absence of `/etc/nv_tegra_release`)
- Builds and installs open-source dependencies (opentelemetry, civetweb, prometheus-cpp, azure-iot-sdk)
- Builds all source components and installs them directly to `/opt/nvidia/deepstream/deepstream-<NVDS_VERSION>/`

```bash
sudo bash build.sh
```

Default CUDA version is architecture-dependent (`13.1` for x86_64, `13.0` for aarch64/sbsa/DGX Spark). To override:

```bash
sudo CUDA_VER=13.1 bash build.sh # x86
sudo CUDA_VER=13.0 bash build.sh # aarch64
```

To override the target DeepStream version (default: 9.0):

```bash
sudo NVDS_VERSION=9.0 bash build.sh
```

After first run, clear the GStreamer plugin cache so it picks up newly installed plugins:

```bash
rm -rf ~/.cache/gstreamer-1.0/
```

**Build outputs:**
- GStreamer plugins → `/opt/nvidia/deepstream/deepstream-<NVDS_VERSION>/lib/gst-plugins/`
- Utility libs → `/opt/nvidia/deepstream/deepstream-<NVDS_VERSION>/lib/`
- Sample app binaries → `/opt/nvidia/deepstream/deepstream-<NVDS_VERSION>/bin/`
- service-maker app bins → `/opt/nvidia/deepstream/deepstream-<NVDS_VERSION>/bin/service-maker-<app>`
- service-maker modules → `/opt/nvidia/deepstream/deepstream-<NVDS_VERSION>/service-maker/modules/`

---

## service-maker — Local Compilation

Individual service-maker apps can be compiled locally without running `build.sh`.
From within any app directory (e.g. `src/service-maker/sources/apps/cpp/deepstream_test1_app/`):

```bash
mkdir build && cd build && cmake .. && make
```

The binary is placed in the local `build/` directory and nothing is installed to `/opt`.
See each app's `README` for usage instructions.
138 changes: 138 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/usr/bin/env bash
# Build and install all DeepStream mono-repo components.
# Usage: bash build.sh [CUDA_VER=<ver>]
set -e

ARCH=$(uname -m)
case "$ARCH" in
x86_64) PLATFORM=x86; CUDA_VER_DEFAULT=13.1 ;;
aarch64)
# Distinguish Jetson (has /etc/nv_tegra_release) from SBSA server hardware
if [ -f /etc/nv_tegra_release ]; then
PLATFORM=aarch64
else
PLATFORM=sbsa
fi
CUDA_VER_DEFAULT=13.0
;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac

CUDA_VER=${CUDA_VER:-$CUDA_VER_DEFAULT}
NVDS_VERSION=${NVDS_VERSION:-9.0}
SM_APP_BUILD=/tmp/ds-sm-apps
SM_MOD_BUILD=/tmp/ds-sm-modules
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)

# Extra make flags for SBSA — passes AARCH64_IS_SBSA=1 to all Makefiles
PLATFORM_MAKE_FLAGS=
[ "$PLATFORM" = "sbsa" ] && PLATFORM_MAKE_FLAGS="AARCH64_IS_SBSA=1"

# ---------------------------------------------------------------------------
# Prerequisites: install open-source dependencies
# (Proprietary prebuilt libs are provided by the DS 9.0 deb install at
# /opt/nvidia/deepstream/deepstream-${NVDS_VERSION}/lib/.)
# ---------------------------------------------------------------------------
echo "==> Installing open-source dependencies"
sudo NVDS_VERSION=$NVDS_VERSION bash "$SCRIPT_DIR/scripts/install_opensource_deps.sh"

echo "==> Building PLATFORM=$PLATFORM CUDA_VER=$CUDA_VER (outputs directly to /opt/nvidia/deepstream/deepstream-${NVDS_VERSION}/)"

MK="CUDA_VER=$CUDA_VER NVDS_VERSION=$NVDS_VERSION $PLATFORM_MAKE_FLAGS"

# nvds_rest_server must be built before gstnvdscustomhelper (it links against it)
make -C src/utils/nvds_rest_server $MK

# gst-utils (order matters — gstnvcustomhelper must come first)
make -C src/gst-utils/gstnvcustomhelper $MK
make -C src/gst-utils/gst-nvdssr $MK
make -C src/gst-utils/gstnvdscustomhelper $MK

# Utils (no top-level Makefile — build each individually)
for dir in src/utils/*/; do
make -C "$dir" $MK 2>/dev/null || true
done

# nvds_msgapi message broker adaptors (Makefiles live one level deeper than
# the rest of src/utils, and azure_protocol_adaptor splits further into
# device_client/ and module_client/).
for dir in src/utils/nvds_msgapi/*/; do
if [ -f "$dir/Makefile" ]; then
make -C "$dir" $MK 2>/dev/null || true
else
for sub in "$dir"*/; do
[ -f "$sub/Makefile" ] && make -C "$sub" $MK 2>/dev/null || true
done
fi
done

# GStreamer plugins (no top-level Makefile — build each individually)
for dir in src/gst-plugins/*/; do
make -C "$dir" $MK 2>/dev/null || true
done

# Sample apps (no top-level Makefile — build each individually)
# Build to a staging dir first so a failed link step does not delete the
# deb-installed binary from the DS bin dir (make removes its output on error).
SA_BIN_STAGE=/tmp/ds-sample-apps-bin
DS_BIN=/opt/nvidia/deepstream/deepstream-${NVDS_VERSION}/bin
mkdir -p "$SA_BIN_STAGE"
for dir in src/apps/sample_apps/*/; do
make -C "$dir" $MK BIN_DIR="$SA_BIN_STAGE" 2>/dev/null || true
for bin in "$SA_BIN_STAGE"/deepstream-*; do
[ -f "$bin" ] && [ -x "$bin" ] && cp -v "$bin" "$DS_BIN/" || true
done
rm -f "$SA_BIN_STAGE"/deepstream-*
done
rm -rf "$SA_BIN_STAGE"

# Prepare Eigen lib
sudo apt update || true
sudo apt install -y libeigen3-dev
sudo ln -sf /usr/include/eigen3/Eigen /usr/include/Eigen

#Customized Yolo postprocessing lib
make -C tools/yolo_deepstream/deepstream_yolo/nvdsinfer_custom_impl_Yolo/ $MK 2>/dev/null || true

# tao-apps — build and install via top-level Makefile
git submodule update --init --recursive || true
make -C src/apps/tao_apps $MK 2>/dev/null || true

# Reference apps (no top-level Makefile — build each individually)
RA_BIN_STAGE=/tmp/ds-reference-apps-bin
mkdir -p "$RA_BIN_STAGE"
for dir in src/apps/reference_apps/*/; do
make -C "$dir" $MK BIN_DIR="$RA_BIN_STAGE" 2>/dev/null || true
for bin in "$RA_BIN_STAGE"/deepstream-*; do
[ -f "$bin" ] && [ -x "$bin" ] && cp -v "$bin" "$DS_BIN/" || true
done
rm -f "$RA_BIN_STAGE"/deepstream-*
done
rm -rf "$RA_BIN_STAGE"

# service-maker apps (cmake-based) — build and install
SM_BIN_INSTALL=/opt/nvidia/deepstream/deepstream-${NVDS_VERSION}/bin
for dir in src/service-maker/sources/apps/cpp/*/; do
app=$(basename "$dir")
cmake -S "$dir" -B "$SM_APP_BUILD/$app" -DCMAKE_BUILD_TYPE=Release
cmake --build "$SM_APP_BUILD/$app" -j$(nproc)
for bin in "$SM_APP_BUILD/$app"/deepstream-*; do
[ -f "$bin" ] && [ -x "$bin" ] || continue
name=$(basename "$bin" | sed 's/^deepstream-/service-maker-/')
cp -v "$bin" "$SM_BIN_INSTALL/$name"
done
done
rm -rf "$SM_APP_BUILD"

# service-maker modules (cmake-based) — build and install
SM_MODULES_INSTALL=/opt/nvidia/deepstream/deepstream-${NVDS_VERSION}/service-maker/modules
mkdir -p "$SM_MODULES_INSTALL"
for dir in src/service-maker/sources/modules/*/; do
mod=$(basename "$dir")
cmake -S "$dir" -B "$SM_MOD_BUILD/$mod" -DCMAKE_BUILD_TYPE=Release
cmake --build "$SM_MOD_BUILD/$mod" -j$(nproc)
cp -v "$SM_MOD_BUILD/$mod/lib${mod}.so" "$SM_MODULES_INSTALL/"
done
rm -rf "$SM_MOD_BUILD"

echo "==> Done"
19 changes: 19 additions & 0 deletions src/apps/sample_apps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,22 @@ Refer to the `README` in each app's directory for app-specific prerequisites, ru
| App | Binary | Description |
|---|---|---|
| `deepstream-opencv-test` | `deepstream-opencv-test` | Access frame data in CPU memory for OpenCV processing. |

### Triton Inference Server

These samples do not produce a standalone binary. Each builds an `nvinferserver`
custom-process library (`.so`) and is driven by the deb-installed `deepstream-app`
with the included config file. See each sample's `README` for the prerequisite
Triton container setup and model download steps.

| Sample | Library | Description |
|---|---|---|
| `TritonBackendEnsemble` | `libnvdstriton_custom_impl_ensemble.so` | Triton ensemble model used as SGIE plus a custom Triton C++ backend that reads DeepStream stream IDs. |
| `TritonOnnxYolo` | `libnvdstriton_custom_impl_yolo.so` | DS-Triton custom-lib for ONNX YoloV3 with dynamic-sized output tensors and multi-input postprocessing. |

Run flow:

```bash
cd src/apps/sample_apps/<TritonSample>
deepstream-app -c <included-config>.txt
```
22 changes: 22 additions & 0 deletions src/apps/sample_apps/TritonBackendEnsemble/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
################################################################################
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
# All rights reserved.
# SPDX-License-Identifier: LicenseRef-NvidiaProprietary
################################################################################

# Delegates to the nvdsinferserver custom-process library so the mono-repo
# build.sh sample_apps loop picks this sample up. The Triton C++ custom
# backend under nvds_triton_cpp_custom_backend/ is built separately via cmake
# (see README) and is not wired into build.sh.

SUBDIRS := nvdsinferserver_custom_impl_ensemble

.PHONY: all clean $(SUBDIRS)

all: $(SUBDIRS)

$(SUBDIRS):
$(MAKE) -C $@

clean:
$(MAKE) -C nvdsinferserver_custom_impl_ensemble clean
Loading