官网地址:https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html
NVIDIA® DeepStream Software Development Kit (SDK) is an accelerated AI framework to build intelligent video analytics (IVA) pipelines. DeepStream runs on NVIDIA® T4, NVIDIA® Ampere and platforms such as NVIDIA® Jetson™ Nano, NVIDIA® Jetson AGX Xavier™, NVIDIA® Jetson Xavier NX™, NVIDIA®Jetson™ TX1 and TX2.
1. Jetson Setup
在安装 DeepStream SDK 之前,我们先来看一下如何为 Jetson 做些准备工作。
1.1 安装 Jetson SDK 组件
下载 NVIDIA SDK Manager,地址为 https://developer.nvidia.com/embedded/jetpack。 你接下来会基于这套系统安装 JetPack 4.5.1 GA (对应 L4T 32.5.1 发发布版本) 。
-
NVIDIA SDK Manager 是一个图形化的应用程序,负责烧录和安装 Jetpack 软件包。
-
烧录过程持续大约 10-30 分钟,这取决于你使用的电脑主机系统
这里我得补充说明一下。对于 Jetson 来讲,上述过程包括:
- 下载 Jetson 系统镜像。这个要根据你的硬件型号选择对应的镜像即可。我用的是 Nano 2G 版本,下载后得到文件 jetson-nano-2gb-sd-card-image。我在 Win10 下给它加上扩展名 tar,解压出镜像文件 sd-blob.img。
- 用软件 balenaEtcher 烧录 SD 卡,建议选择 64G 容量的卡,不然的话你会发现开发过程中容量不够用。
上述过程我会专门写文详细介绍,目前先大致了解这么多。
官方提示:如果你是用 Jetson Nano 或 Jetson Xavier NX 开发套件,你可以从 https://developer.nvidia.com/embedded/jetpack 下载 SD卡镜像文件。这套镜像包含了 CUDA、TensorRT 和 cuDNN。
1.2 安装依赖项
输入下面的命令行,安装依赖项:
$ sudo apt install \
libssl1.0.0 \
libgstreamer1.0-0 \
gstreamer1.0-tools \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
libgstrtspserver-1.0-0 \
libjansson4=2.11-1
安装 librdkafka (为消息代理启用Kafka协议适配器)
-
从 GitHub 克隆 librdkafka 库:
$ git clone https://github.com/edenhill/librdkafka.git -
配置并编译构建库:
$ cd librdkafka $ git reset --hard 7101c2310341ab3f4675fc565f64f0967e135a6a $ ./configure $ make $ sudo make install -
把生成的库文件复制到 deepstream 目录:
$ sudo mkdir -p /opt/nvidia/deepstream/deepstream-5.1/lib $ sudo cp /usr/local/lib/librdkafka* /opt/nvidia/deepstream/deepstream-5.1/lib
1.3 安装 DeepStream SDK
-
Method 1: 使用 SDK Manager
在安装 JetPack 4.5.1 时从 Additional SDKs 中选择 DeepStreamSDK。
-
Method 2: 使用 DeepStream tar 压缩包安装
-
下载 DeepStream 5.1 Jetson tar 压缩包
eepstream_sdk_v5.1.0_jetson.tbz2 到Jetson 设备。 -
输入下面的命令解压并安装 DeepStream SDK:
$ sudo tar -xvf deepstream_sdk_v5.1.0_jetson.tbz2 -C / $ cd /opt/nvidia/deepstream/deepstream-5.1 $ sudo ./install.sh $ sudo ldconfig
-
亲测这个方法好使,后面的方法就不多介绍了。
-
Method 3: Using the DeepStream Debian package
Download the DeepStream 5.1 Jetson Debian package
deepstream-5.1_5.1.0-1_arm64.deb, to the Jetson device. Then enter the command:$ sudo apt-get install ./deepstream-5.1_5.1.0-1_arm64.debNote
If you install the DeepStream SDK Debian package using the
dpkgcommand, you must install the following packages before installing the debian package:-
libgstrtspserver-1.0-0 -
libgstreamer-plugins-base1.0-dev
-
-
Method 4: Using the apt-server
-
Open the apt source configuration file in a text editor, using a command similar to
$ sudo vi /etc/apt/sources.list.d/nvidia-l4t-apt-source.list -
Change the repository name and download URL in the deb commands shown below:
deb https://repo.download.nvidia.com/jetson/common r32.5 main -
Save and close the source configuration file.
-
Enter the commands:
$ sudo apt update $ sudo apt install deepstream-5.1
-
-
Method 5: Use Docker container DeepStream docker containers are available on NGC. See the Docker Containers section to learn about developing and deploying DeepStream using docker containers.
1.4 运行 deepstream-app (the reference application——参考应用)
-
导航到开发套件的样例目录。
-
输入下面的命令运行样例程序:
$ deepstream-app -c <path_to_config_file>Where
<path_to_config_file>is the pathname of one of the reference application’s configuration files, found inconfigs/deepstream-app/. See Package Contents for a list of the available files.Note
-
You can find sample configuration files under
/opt/nvidia/deepstream/deepstream-5.1/samplesdirectory. Enter this command to see application usage:$ deepstream-app --help -
To save TensorRT Engine/Plan file, run the following command:
$ sudo deepstream-app -c <path_to_config_file>
-
To show labels in 2D Tiled display view, expand the source of interest with mouse left-click on the source. To return to the tiled display, right-click anywhere in the window.
Keyboard selection of source is also supported. On the console where application is running, press the
zkey followed by the desired row index (0 to 9), then the column index (0 to 9) to expand the source. To restore 2D Tiled display view, presszagain.
... ...
Jetson Nano 已经安装了 GStreamer,但是,nVidia 并没有完成配置, include 路径需要自己在配置一下才行。方法如下:
在 /etc/profile 文件最后添加以下两行内容即可:
export C_INCLUDE_PATH=/usr/include/gstreamer-1.0:/usr/include/glib-2.0:/usr/lib/aarch64-linux-gnu/glib-2.0/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/include/gstreamer-1.0:/usr/include/glib-2.0:/usr/lib/aarch64-linux-gnu/glib-2.0/include:$CPLUS_INCLUDE_PATH
保存后重启系统,即可。用下面的程序(文件名 basic-tutorial-1.c )测试一下:
#include <gst/gst.h>
int
main (int argc, char *argv[])
{
GstElement *pipeline;
GstBus *bus;
GstMessage *msg;
/* Initialize GStreamer */
gst_init (&argc, &argv);
/* Build the pipeline */
pipeline =
gst_parse_launch
("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm",
NULL);
/* Start playing */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg =
gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
/* Free resources */
if (msg != NULL)
gst_message_unref (msg);
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}
用下面的命令编译:
gcc basic-tutorial-1.c -o basic-tutorial-1 `pkg-config --cflags --libs gstreamer-1.0`
运行编译好的程序,应该能看到来自 https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm一段很有趣的视频。
其实到此为止,已经可以正常工作了,本文就先写这么多,谢谢阅读!

本文介绍如何在NVIDIA Jetson Nano上安装DeepStream SDK,包括安装前的准备、安装依赖项、安装SDK的不同方法及运行示例程序。此外还提供了解决GStreamer配置问题的方案。
7224





