Link to this section在 NVIDIA Jetson 上使用 DeepStream SDK 和 TensorRT 运行 Ultralytics YOLO26#
Watch: How to use Ultralytics YOLO26 models with NVIDIA Deepstream on Jetson Orin NX 🚀
本综合指南详细介绍了如何使用 DeepStream SDK 和 TensorRT 在 NVIDIA Jetson 设备上部署 Ultralytics YOLO26。在这里,我们使用 TensorRT 来最大限度地提高 Jetson 平台上的推理性能。

This guide has been tested with NVIDIA Jetson Orin Nano Super Developer Kit running the latest stable JetPack release of JP6.1, Seeed Studio reComputer J4012 which is based on NVIDIA Jetson Orin NX 16GB running JetPack release of JP5.1.3 and Seeed Studio reComputer J1020 v2 which is based on NVIDIA Jetson Nano 4GB running JetPack release of JP4.6.4. It is expected to work across all the NVIDIA Jetson hardware lineup including latest and legacy.
Link to this section什么是 NVIDIA DeepStream?#
NVIDIA's DeepStream SDK is a complete streaming analytics toolkit based on GStreamer for AI-based multi-sensor processing, video, audio, and image understanding. It's ideal for vision AI developers, software partners, startups, and OEMs building IVA (Intelligent Video Analytics) apps and services. You can now create stream-processing pipelines that incorporate neural networks and other complex processing tasks like tracking, video encoding/decoding, and video rendering. These pipelines enable real-time analytics on video, image, and sensor data. DeepStream's multi-platform support gives you a faster, easier way to develop vision AI applications and services on-premise, at the edge, and in the cloud.
Link to this section前提条件#
在开始学习本指南之前:
- 请访问我们的文档 快速入门指南:在 NVIDIA Jetson 上使用 Ultralytics YOLO26,将你的 NVIDIA Jetson 设备配置好 Ultralytics YOLO26 环境。
- 根据你的 JetPack 版本安装 DeepStream SDK。
- 对于 JetPack 4.6.4,请安装 DeepStream 6.0.1。
- 对于 JetPack 5.1.3,请安装 DeepStream 6.3。
- 对于 JetPack 6.1,请安装 DeepStream 7.1。
- 对于 JetPack 7.1,请安装 DeepStream 9.0。
在本指南中,我们使用了 Debian 包方法将 DeepStream SDK 安装到 Jetson 设备上。你还可以访问 DeepStream SDK on Jetson (Archived) 以获取旧版本的 DeepStream。
Link to this sectionYOLO26 的 DeepStream 配置#
在这里,我们使用 marcoslucianops/DeepStream-Yolo GitHub 仓库,它包含了 NVIDIA DeepStream SDK 对 YOLO 模型的功能支持。我们感谢 marcoslucianops 所做的贡献!
-
安装 Ultralytics 及其必要的依赖项
cd ~ pip install -U pip git clone https://github.com/ultralytics/ultralytics cd ultralytics pip install -e ".[export]" onnxslim -
克隆 DeepStream-Yolo 仓库
cd ~ git clone https://github.com/marcoslucianops/DeepStream-Yolo -
将
export_yolo26.py文件从DeepStream-Yolo/utils目录复制到ultralytics文件夹中cp ~/DeepStream-Yolo/utils/export_yolo26.py ~/ultralytics cd ultralytics -
从 YOLO26 发布页面下载你选择的 Ultralytics YOLO26 检测模型 (.pt)。这里我们使用 yolo26s.pt。
wget https://github.com/ultralytics/assets/releases/download/v8.4.0/yolo26s.pt
你也可以使用自定义训练的 YOLO26 模型。
-
将模型转换为 ONNX
python3 export_yolo26.py -w yolo26s.pt
对于 DeepStream 5.1,请删除 --dynamic 参数并使用 opset 12 或更低版本。默认的 opset 是 17。
--opset 12要更改推理尺寸(默认:640)
-s SIZE
--size SIZE
-s HEIGHT WIDTH
--size HEIGHT WIDTH1280 的示例:
-s 1280
or
-s 1280 1280简化 ONNX 模型(适用于 DeepStream >= 6.0)
--simplify使用动态批处理大小(适用于 DeepStream >= 6.1)
--dynamic使用静态批处理大小(以批处理大小 = 4 为例)
--batch 4-
将生成的
.onnx模型文件和labels.txt文件复制到DeepStream-Yolo文件夹cp yolo26s.pt.onnx labels.txt ~/DeepStream-Yolo cd ~/DeepStream-Yolo -
根据已安装的 JetPack 版本设置 CUDA 版本
对于 JetPack 4.6.4:
export CUDA_VER=10.2对于 JetPack 5.1.3:
export CUDA_VER=11.4对于 JetPack 6.1:
export CUDA_VER=12.6 -
编译库
make -C nvdsinfer_custom_impl_Yolo clean && make -C nvdsinfer_custom_impl_Yolo -
根据你的模型编辑
config_infer_primary_yolo26.txt文件(以具有 80 个类别的 YOLO26s 为例)[property] ... onnx-file=yolo26s.pt.onnx ... num-detected-classes=80 ... -
编辑
deepstream_app_config文件... [primary-gie] ... config-file=config_infer_primary_yolo26.txt -
你也可以在
deepstream_app_config文件中更改视频源。此处加载了一个默认的视频文件... [source0] ... uri=file:///opt/nvidia/deepstream/deepstream/samples/streams/sample_1080p_h264.mp4
Link to this section运行推理#
deepstream-app -c deepstream_app_config.txt在开始推理之前,生成 TensorRT 引擎文件需要较长时间,请耐心等待。

If you want to convert the model to FP16 precision, simply set model-engine-file=model_b1_gpu0_fp16.engine and network-mode=2 inside config_infer_primary_yolo26.txt
Link to this sectionINT8 校准#
如果你想使用 INT8 精度进行推理,需要遵循以下步骤:
目前 INT8 无法在 TensorRT 10.x 上工作。本节指南已在 TensorRT 8.x 上进行了测试,预计可以正常工作。
-
设置
OPENCV环境变量export OPENCV=1 -
编译库
make -C nvdsinfer_custom_impl_Yolo clean && make -C nvdsinfer_custom_impl_Yolo -
对于 COCO 数据集,下载 val2017,解压并移动到
DeepStream-Yolo文件夹 -
为校准图像创建一个新目录
mkdir calibration -
运行以下命令从 COCO 数据集中随机选择 1000 张图像进行校准
for jpg in $(ls -1 val2017/*.jpg | sort -R | head -1000); do cp ${jpg} calibration/ done
NVIDIA 建议至少使用 500 张图像以获得良好的精度。在此示例中,选择了 1000 张图像以获得更高的精度(图像越多 = 精度越高)。你可以通过 head -1000 设置它。例如,对于 2000 张图像,使用 head -2000。此过程可能需要很长时间。
-
创建包含所有选定图像的
calibration.txt文件realpath calibration/*jpg > calibration.txt -
设置环境变量
export INT8_CALIB_IMG_PATH=calibration.txt export INT8_CALIB_BATCH_SIZE=1
较高的 INT8_CALIB_BATCH_SIZE 值将带来更高的精度和更快的校准速度。请根据你的 GPU 内存进行设置。
-
更新
config_infer_primary_yolo26.txt文件从
... model-engine-file=model_b1_gpu0_fp32.engine #int8-calib-file=calib.table ... network-mode=0 ...到
... model-engine-file=model_b1_gpu0_int8.engine int8-calib-file=calib.table ... network-mode=1 ...
Link to this section运行推理#
deepstream-app -c deepstream_app_config.txtLink to this section多流设置#
Watch: How to Run Multi-Stream Inference with Ultralytics YOLO26 using NVIDIA DeepStream on Jetson Orin 🚀
要在单个 DeepStream 应用程序下设置多个流,请对 deepstream_app_config.txt 文件进行以下更改:
-
更改行数和列数以根据你想要的流数量构建网格显示。例如,对于 4 个流,我们可以添加 2 行和 2 列。
[tiled-display] rows=2 columns=2 -
设置
num-sources=4并添加所有四个流的uri条目。[source0] enable=1 type=3 uri=path/to/video1.jpg uri=path/to/video2.jpg uri=path/to/video3.jpg uri=path/to/video4.jpg num-sources=4
Link to this section运行推理#
deepstream-app -c deepstream_app_config.txt
Link to this section基准测试结果#
以下基准测试总结了 YOLO26 模型在 NVIDIA Jetson Orin NX 16GB 上,以 640x640 输入尺寸、在不同 TensorRT 精度级别下的性能表现。
Link to this section对比图#

Link to this section详细对比表#
| 格式 | 状态 | 推理时间 (ms/im) |
|---|---|---|
| TensorRT (FP32) | ✅ | 8.64 |
| TensorRT (FP16) | ✅ | 5.27 |
| TensorRT (INT8) | ✅ | 4.54 |
Link to this section致谢#
本指南最初由 Seeed Studio 的朋友 Lakshantha 和 Elaine 创建。
Link to this section常见问题解答#
Link to this section我该如何在 NVIDIA Jetson 设备上设置 Ultralytics YOLO26?#
要在 NVIDIA Jetson 设备上设置 Ultralytics YOLO26,你首先需要安装与你的 JetPack 版本兼容的 DeepStream SDK。请按照我们的快速入门指南中的分步说明配置你的 NVIDIA Jetson 以进行 YOLO26 部署。
Link to this section在 NVIDIA Jetson 上将 TensorRT 与 YOLO26 一起使用有什么好处?#
在 NVIDIA Jetson 设备上,将 TensorRT 与 YOLO26 结合使用可以优化推理模型,显著降低延迟并提高吞吐量。TensorRT 通过层融合、精度校准和内核自动调优,提供高性能、低延迟的深度学习推理。这实现了更快、更高效的执行,特别适用于视频分析和自动驾驶机器等实时应用。
Link to this section我可以跨不同的 NVIDIA Jetson 硬件运行带有 DeepStream SDK 的 Ultralytics YOLO26 吗?#
是的,本指南关于使用 DeepStream SDK 和 TensorRT 部署 Ultralytics YOLO26 的说明兼容整个 NVIDIA Jetson 产品系列。这包括配备 JetPack 5.1.3 的 Jetson Orin NX 16GB 以及配备 JetPack 4.6.4 的 Jetson Nano 4GB 等设备。有关详细步骤,请参阅YOLO26 的 DeepStream 配置一节。
Link to this section我该如何将 YOLO26 模型转换为 ONNX 以供 DeepStream 使用?#
To convert a YOLO26 model to ONNX format for deployment with DeepStream, use the utils/export_yolo26.py script from the DeepStream-Yolo repository.
以下是一个命令示例:
python3 utils/export_yolo26.py -w yolo26s.pt --opset 12 --simplify有关模型转换的更多详细信息,请查看我们的模型导出部分。
Link to this sectionNVIDIA Jetson Orin NX 上的 YOLO 性能基准测试结果如何?#
YOLO26 模型在 NVIDIA Jetson Orin NX 16GB 上的性能会根据 TensorRT 精度级别而有所不同。例如,YOLO26s 模型可实现:
- FP32 精度:14.6 毫秒/图像,68.5 FPS
- FP16 精度:7.94 毫秒/图像,126 FPS
- INT8 精度:5.95 毫秒/张,168 FPS
这些基准测试强调了在 NVIDIA Jetson 硬件上使用 TensorRT 优化后的 YOLO26 模型的高效性与性能。更多详情,请查阅我们的 基准测试结果 部分。