NVIDIA DeepStream
SDK
DeepStream의 멀티 플랫폼 지원을 통해 비전 AI 애플리케이션과 서비스를 더 빠르게 개발할 수 있습니다. 버튼 클릭 한 번으로 온프레미스, 에지 to 엣지 및 클라우드에 배포할 수 있습니다.
애플리케이션 | 모델 | 추적기 | 추론 분해능 | 정밀도 |
사람 감지 | PeopleNet-ResNet34 (버전 2.5) | 추적기 없음 | 960x544 | INT8 |
사람 감지 | PeopleNet-ResNet34 (버전 2.5) | NvDCF | 960x544 | INT8 |
차량 번호판 인식 | TrafficCamNet | NvDCF | 960x544 | INT8 |
3D 신체 포즈 추정 | PeopleNet-ResNet34 BodyPose3D | NvDCF | 960x544 | INT8 |
액션 인식 | ActionRecognitionNet (3DConv) | 추적기 없음 | 224x224x3x32 | FP16 |
Gst-nvtracker
The Gst-nvtracker plugin allows the DS pipeline to use a low-level tracker library to track the detected objects over time persistently with unique IDs. It supports any low-level library that implements NvDsTracker API, including the reference implementations provided by the NvMultiObjectTracker library: IOU, NvSORT, NvDeepSORT and NvDCF trackers. As part of this API, the plugin queries the low-level library for capabilities and requirements concerning the input format, memory type, and additional feature support. Based on these queries, the plugin then converts the input frame buffers into the format requested by the low-level tracker library. For example, the NvDeepSORT and NvDCF trackers use NV12 or RGBA, while IOU and NvSORT requires no video frame buffers at all.
Install
Install prerequisite packages
Enter the following commands to install the prerequisite packages:
$ sudo apt install \
libssl3 \
libssl-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 \
libyaml-cpp-dev
INFORMATION |
때때로 RTSP 스트림을 사용하면 애플리케이션이 EOS에 도달하는 데 멈춥니다. 이는 rtpjitterbuffer 구성 요소의 문제 때문입니다. 이 문제를 해결하기 위해 |
DeepStream Single-View 3D Tracking
- NVIDIA DeepStream 7.0 Milestone Release for Next-Gen Vision AI Development | NVIDIA Technical Blog
- 3D Multi-Object Tracking/Multi-Object Tracking/Multiple object tracking/MOT/Motion estimation/Object Tracking 참조.
DeepStream container for Enterprise Grade GPUs
컨테이너 목록:
Container Name | Architecture | License Type | Notes |
| Multi-Arch | Deployment | The DeepStream Triton container enables inference using Triton Inference Server. With Triton developers can run inference natively using TensorFlow, TensorFlow-TensorRT, PyTorch and ONNX-RT. Inference with Triton is supported in the reference application (deepstream-app) |
| Multi-Arch | Deployment | The DeepStream samples container extends the base container to also include sample applications that are included in the DeepStream SDK along with associated config files, models, and streams. This container is ideal to understand and explore the DeepStream SDK using the provided samples. |
| x86 | Development | The DeepStream development container is the recommended container to get you started as it includes Graph Composer, the build toolchains, development libraries and packages necessary for building DeepStream reference applications within the container. This container is slightly larger in size by virtue of including the build dependencies. |
| SBSA | Developer Preview | SBSA container for ARM based servers and systems. |
잘모르겠으면 "deepstream:7.1-samples-multiarch" 을 사용:
GStreamer Plugin Overview
- GStreamer Plugin Overview — DeepStream documentation
- MetaData in the DeepStream SDK
- Gst-nvdspreprocess (Alpha)
- Gst-nvinfer
- Gst-nvinferserver
- Gst-nvtracker
- Gst-nvstreammux
- Gst-nvstreammux New
- Gst-nvstreamdemux
- Gst-nvmultistreamtiler
- Gst-nvdsosd
- Gst-nvdsmetautils
- Gst-nvdsvideotemplate
- Gst-nvdsaudiotemplate
- Gst-nvvideoconvert
- Gst-nvdewarper
- Gst-nvof
- Gst-nvofvisual
- Gst-nvsegvisual
- Gst-nvvideo4linux2
- Gst-nvjpegdec
- Gst-nvimagedec
- Gst-nvjpegenc
- Gst-nvimageenc
- Gst-nvmsgconv
- Gst-nvmsgbroker
- Gst-nvdsanalytics
- Gst-nvdsudpsrc
- Gst-nvdsudpsink
- Gst-nvdspostprocess (Alpha)
- Gst-nvds3dfilter
- Gst-nvds3dbridge
- Gst-nvds3dmixer
- Gst-NvDsUcx
- Gst-nvdsxfer
- Gst-nvvideotestsrc
- Gst-nvmultiurisrcbin
- Gst-nvurisrcbin
CUDA 라이브러리 설치 방법
-
sudo apt-get -y update
-
sudo apt-get -y install cuda
-
sudo apt-get -y install cuda-toolkit-12-2
- 업데이트 대안을 사용하여 도커 내부에서 기본 CUDA 버전을 Cuda-12.2로 변경:
update-alternatives --set cuda /usr/local/cuda-12.2
- 도커 내부에서 현재 사용 중인 CUDA 버전을 확인하려면 다음을 실행합니다:
update-alternatives --display cuda
.etlt
file extension 이란?
NOTE |
ChatGPT에서 생성한 답변임. 차 후 확인 필요. |
DeepStream SDK는 NVIDIA가 제공하는 스트리밍 분석 툴킷으로, 주로 실시간 영상 분석, AI 기반의 영상 처리 등에 사용됩니다. DeepStream에서 사용하는 파일 확장자 중에서 .etlt 파일은 "효율적인 TensorRT 런타임 파일"(Efficient TensorRT runtime files)로 알려져 있습니다. ETLT 파일은 DeepStream 애플리케이션에서 TensorFlow 또는 ONNX 모델을 최적화하여 TensorRT 엔진을 만드는 데 사용되는 중간 파일 형식입니다.
이러한 .etlt 파일은 NVIDIA Transfer Learning Toolkit(TLT)에서 생성됩니다. TLT는 사전 학습된 AI 모델을 사용자가 재학습하여 자체 애플리케이션에 맞춤화할 수 있는 도구입니다. ETLT 파일은 TLT 모델을 TensorRT로 변환하기 전에 제공되는 파일 형식입니다. DeepStream에서 ETLT 파일을 사용하면 TensorRT로 변환하여 고성능 AI 추론을 할 수 있습니다.
요약:
- ETLT 파일: NVIDIA Transfer Learning Toolkit(TLT)에서 생성된 중간 파일 형식.
- 용도: TensorRT 엔진으로 변환하여 DeepStream 애플리케이션에서 사용.
이 파일을 사용하려면, NVIDIA의 TLT를 통해 모델을 훈련하거나 재학습한 후, 이를 TensorRT 엔진으로 변환해야 합니다.
C 레벨의 DeepStream SDK 에서 로드하여 호출하는 방법
NOTE |
ChatGPT에서 생성한 답변임. 차 후 확인 필요. |
DeepStream SDK에서 .etlt 파일을 사용하여 모델을 로드하고 호출하려면, 기본적으로 TensorRT 엔진을 생성해야 합니다. NVIDIA의 TensorRT는 고성능 추론을 위한 딥러닝 최적화 도구이며, DeepStream SDK는 이를 사용하여 AI 모델을 실행합니다. C API를 통해 이를 구현하는 일반적인 과정은 다음과 같습니다.
ETLT 파일을 TensorRT 엔진으로 변환
DeepStream SDK 자체는 ETLT 파일을 직접 사용하지 않고, TensorRT 엔진 파일로 변환해야 합니다. 이 과정은 NVIDIA Transfer Learning Toolkit(TLT) 또는 TensorRT Python API를 사용하여 이루어집니다. 일반적인 변환 명령어는 다음과 같습니다:
위의 명령어에서:
-
-k
- 모델 변환 키 (TLT로 암호화된 모델을 해독하는 데 필요). -
-o
- 출력 레이어. -
-e
- 변환된 TensorRT 엔진 파일의 경로. -
input_model.etlt
- 변환할 ETLT 파일.
DeepStream에서 TensorRT 엔진을 로드
ETLT 파일을 TensorRT 엔진 파일로 변환한 후, DeepStream 애플리케이션에서 이 엔진 파일을 로드하여 추론에 사용할 수 있습니다. 다음은 기본적인 C API 코드 구조입니다.
모델 로드
C에서 TensorRT 엔진을 로드하는 방법은 DeepStream에서 제공하는 nvinfer 플러그인을 사용합니다. 이 플러그인은 사전 훈련된 모델을 로드하고 이를 기반으로 추론을 수행합니다. nvinfer는 GstElement를 통해 사용됩니다.
// nvinfer 플러그인 요소 생성
GstElement *nvinfer = gst_element_factory_make("nvinfer", "primary-nvinference-engine");
// TensorRT 엔진 파일을 지정
g_object_set(G_OBJECT(nvinfer), "model-engine-file", "path/to/your/model.trt", NULL);
추론 호출
모델을 로드한 후, GstPipeline을 구성하여 동영상을 스트리밍하면서 추론을 수행할 수 있습니다. 기본적인 파이프라인 구조는 다음과 같습니다:
GstElement *pipeline = gst_pipeline_new("deepstream-pipeline");
GstElement *source = gst_element_factory_make("filesrc", "file-source");
GstElement *decode = gst_element_factory_make("decodebin", "decode");
GstElement *nvinfer = gst_element_factory_make("nvinfer", "primary-nvinference-engine");
GstElement *sink = gst_element_factory_make("nveglglessink", "video-output");
// 파이프라인에 요소 추가
gst_bin_add_many(GST_BIN(pipeline), source, decode, nvinfer, sink, NULL);
// 요소 간 링크
gst_element_link_many(source, decode, nvinfer, sink, NULL);
추론 설정
nvinfer 요소에서 다양한 추론 설정을 할 수 있습니다. 예를 들어, 배치 크기, 입력 크기, 레이블 파일 등을 설정할 수 있습니다.
g_object_set(G_OBJECT(nvinfer), "batch-size", 1, NULL);
g_object_set(G_OBJECT(nvinfer), "gpu-id", 0, NULL);
g_object_set(G_OBJECT(nvinfer), "config-file-path", "path/to/config_infer_primary.txt", NULL);
config-file-path
에 지정된 파일은 추론 모델에 대한 추가 설정(레이블, 전처리/후처리 방법 등)을 포함합니다.
DeepStream 파이프라인 실행
파이프라인을 구성한 후, gst_element_set_state()로 실행하면 DeepStream이 영상 스트림을 처리하면서 추론을 수행하게 됩니다.
예시 Config 파일 (config_infer_primary.txt)
[property]
gpu-id=0
net-scale-factor=0.017
model-engine-file=path/to/your/model.trt
labelfile-path=path/to/labels.txt
batch-size=1
network-mode=2
num-detected-classes=80
interval=0
gie-unique-id=1
이와 같은 방법으로 DeepStream에서 C API를 사용해 ETLT 파일로부터 변환된 TensorRT 엔진을 로드하고 추론을 수행할 수 있습니다.
참고 사항
- 먼저 .etlt 파일을 .trt 파일로 변환하는 과정이 필수입니다.
- DeepStream 파이프라인에서 nvinfer 요소를 통해 모델을 로드하고 추론을 실행합니다.
- 추론 설정은 별도의 설정 파일을 통해 관리할 수 있습니다.
이 방법을 적용하면 DeepStream SDK에서 C 언어 기반으로 ETLT 모델을 활용한 추론을 수행할 수 있습니다.
answer-jet 셋업
answer-jet 항목 참조.
Troubleshooting
=== unsatisfied condition: cuda>=12.6 ===
출력:
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: Auto-detected mode as 'legacy'
nvidia-container-cli: requirement error: unsatisfied condition: cuda>=12.6, please update your driver to a newer version, or use an earlier cuda container: unknown.
드라이버 업데이트하자. 또는 7.1 버전 대신 6.4 버전 쓰자.
GLib (gthread-posix.c): Unexpected error from C library during 'pthread_setspecific': Invalid argument. Aborting.
NOTE |
Sometimes while running gstreamer pipeline or sample apps, user can encounter error : |
요약하면, Ubuntu 22.04 와 함께 제공되는 glib 2.0-2.72 버전의 버그로 인해 발생된 문제이다. 이 문제는 glib-2.76 에서 해결되었으며, 문제를 해결하려면 설치가 필요합니다.
진행하기에 앞서 glib 버전을 확인해보자.
2.76 보다 작다면 직접 설치가 필요하다.
Migrate glib to newer version
In order to migrate to newer glib version (e.g. 2.76.6) follow below steps:
Prerequisites: Install below packages:
(만약 pip3 명령이 없다면):
NOTE |
On baremetal, use |
Compilation and installation steps:
git clone https://github.com/GNOME/glib.git
cd glib
git checkout <glib-version-branch>
# e.g. 2.76.6
meson build --prefix=/usr
ninja -C build/
cd build/
ninja install
NOTE |
On baremetal, use sudo ninja install to install with root permissions |
Check and confirm the newly installed glib version:
cannot open shared object file
이후 경고들:
(deepstream-app:16): GStreamer-WARNING **: 02:35:33.674: External plugin loader failed. This most likely means that the plugin loader helper binary was not found or could not be run. You might need to set the GST_PLUGIN_SCANNER environment variable if your setup is unusual. This should normally not be required though.
(deepstream-app:16): GStreamer-WARNING **: 02:35:33.709: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstopenmpt.so': libmpg123.so.0: cannot open shared object file: No such file or directory
(deepstream-app:16): GStreamer-WARNING **: 02:35:33.742: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstmpg123.so': libmpg123.so.0: cannot open shared object file: No such file or directory
(deepstream-app:16): GStreamer-WARNING **: 02:35:33.748: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstchromaprint.so': libavcodec.so.58: cannot open shared object file: No such file or directory
(deepstream-app:16): GStreamer-WARNING **: 02:35:33.775: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstmpeg2enc.so': libmpeg2encpp-2.1.so.0: cannot open shared object file: No such file or directory
(deepstream-app:16): GStreamer-WARNING **: 02:35:33.814: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstmpeg2dec.so': libmpeg2.so.0: cannot open shared object file: No such file or directory
(deepstream-app:16): GStreamer-WARNING **: 02:35:33.857: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_udp.so': librivermax.so.1: cannot open shared object file: No such file or directory
(deepstream-app:16): GStreamer-WARNING **: 02:35:33.921: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_inferserver.so': libtritonserver.so: cannot open shared object file: No such file or directory
(deepstream-app:16): GStreamer-WARNING **: 02:35:33.935: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_ucx.so': libucs.so.0: cannot open shared object file: No such file or directory
...
관련 플러그인 로드에 실패함. 결과적으로 해당 라이브러리를 설치해야한다.
설치해도 해당 이슈가 반복되면 Advanced Package Tool#라이브러리를 찾을 수 없지만 패키지로는 설치되어 있다고 출력될 때 항목을 참조.
필요하다면 apt install --reinstall ...
로 재 설치 해야 할 수 있다.
필요한 라이브러리 이름 | Ubuntu 에서 설치할 패키지 이름 |
libmpg123.so.0 | libmpg123-0 |
libavcodec.so.58 | libavcodec58 |
libavutil.so.56 | libavutil56 |
libvpx.so.7 | libvpx7 |
libx264.so.163 | libx264-163 |
libmpeg2encpp-2.1.so.0 | libmpeg2encpp-2.1-0 |
libmpeg2.so.0 | libmpeg2-4 |
libx265.so.199 | libx265-199 |