콘텐츠로 건너뛰기

Ultralytics YOLO11 on NVIDIA Jetson using DeepStream SDK and TensorRT



Watch: How to Run Multiple Streams with DeepStream SDK on Jetson Nano using Ultralytics YOLO11

This comprehensive guide provides a detailed walkthrough for deploying Ultralytics YOLO11 on NVIDIA Jetson devices using DeepStream SDK and TensorRT. Here we use TensorRT to maximize the inference performance on the Jetson platform.

NVIDIA Jetson의 DeepStream

참고

이 가이드는 JP5.1.3의 JetPack 릴리즈를 실행하는 NVIDIA Jetson Orin NX 16GB 기반의 Seeed Studio 재컴퓨터 J4012와 JP4.6.4의 JetPack 릴리즈를 실행하는 NVIDIA Jetson Nano 4GB 기반의 Seeed Studio 재컴퓨터 J1020 v2로 테스트되었습니다. 최신 및 레거시를 포함한 모든 NVIDIA Jetson 하드웨어 라인업에서 작동할 것으로 예상됩니다.

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.

전제 조건

이 가이드를 따르기 전에 먼저 확인하세요:

이 가이드에서는 Jetson 장치에 DeepStream SDK를 설치하는 Debian 패키지 방법을 사용했습니다. 또한 Jetson의 DeepStream SDK(아카이브) 를 방문하여 레거시 버전의 DeepStream에 액세스할 수도 있습니다.

DeepStream Configuration for YOLO11

여기에서는 YOLO 모델에 대한 NVIDIA DeepStream SDK 지원을 포함하는 marcoslucianops/DeepStream-Yolo GitHub 리포지토리를 사용하고 있습니다. 기여해 주신 marcoslucianops의 노고에 감사드립니다!

  1. 설치 종속성

    pip install cmake
    pip install onnxsim
    
  2. 다음 리포지토리를 복제합니다.

    git clone https://github.com/marcoslucianops/DeepStream-Yolo
    cd DeepStream-Yolo
    
  3. Download Ultralytics YOLO11 detection model (.pt) of your choice from YOLO11 releases. Here we use yolov8s.pt.

    wget https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8s.pt
    

    참고

    You can also use a custom trained YOLO11 model.

  4. 모델로 변환 ONNX

    python3 utils/export_yoloV8.py -w yolov8s.pt
    

    위 명령에 아래 인수를 전달합니다.

    DeepStream 6.0.1의 경우, 옵셋 12 이하를 사용합니다. 기본 옵셋은 16입니다.

    --opset 12
    

    추론 크기를 변경하려면(기본값: 640) 다음과 같이 하세요.

    -s SIZE
    --size SIZE
    -s HEIGHT WIDTH
    --size HEIGHT WIDTH
    

    1280의 예입니다:

    -s 1280
    or
    -s 1280 1280
    

    ONNX 모델을 단순화하려면 (DeepStream >= 6.0)

    --simplify
    

    동적 배치 크기 사용(DeepStream >= 6.1)

    --dynamic
    

    정적 배치 크기를 사용하려면(예: 배치 크기 = 4) 다음과 같이 하세요.

    --batch 4
    
  5. 설치된 JetPack 버전에 따라 CUDA 버전을 설정합니다.

    JetPack 4.6.4의 경우:

    export CUDA_VER=10.2
    

    JetPack 5.1.3의 경우:

    export CUDA_VER=11.4
    
  6. 라이브러리 컴파일

    make -C nvdsinfer_custom_impl_Yolo clean && make -C nvdsinfer_custom_impl_Yolo
    
  7. 편집 config_infer_primary_yoloV8.txt 파일(80개의 클래스가 있는 YOLOv8s 의 경우)

    [property]
    ...
    onnx-file=yolov8s.onnx
    ...
    num-detected-classes=80
    ...
    
  8. 편집 deepstream_app_config 파일

    ...
    [primary-gie]
    ...
    config-file=config_infer_primary_yoloV8.txt
    
  9. 다음에서 동영상 소스를 변경할 수도 있습니다. deepstream_app_config 파일을 선택합니다. 여기에 기본 비디오 파일이 로드됩니다.

    ...
    [source0]
    ...
    uri=file:///opt/nvidia/deepstream/deepstream/samples/streams/sample_1080p_h264.mp4
    

추론 실행

deepstream-app -c deepstream_app_config.txt

참고

추론을 시작하기 전에 TensorRT 엔진 파일을 생성하는 데 시간이 오래 걸립니다. 그러니 조금만 기다려주세요.

YOLO11 with deepstream

If you want to convert the model to FP16 precision, simply set model-engine-file=model_b1_gpu0_fp16.engine 그리고 network-mode=2 내부 config_infer_primary_yoloV8.txt

INT8 보정

추론에 INT8 정밀도를 사용하려면 다음 단계를 따라야 합니다.

  1. 설정 OPENCV 환경 변수

    export OPENCV=1
    
  2. 라이브러리 컴파일

    make -C nvdsinfer_custom_impl_Yolo clean && make -C nvdsinfer_custom_impl_Yolo
    
  3. COCO 데이터 세트의 경우 val2017를 클릭하고 추출한 다음 DeepStream-Yolo 폴더

  4. 보정 이미지를 위한 새 디렉터리 만들기

    mkdir calibration
    
  5. 다음을 실행하여 COCO 데이터 세트에서 1000개의 무작위 이미지를 선택하여 보정을 실행합니다.

    for jpg in $(ls -1 val2017/*.jpg | sort -R | head -1000); do \
        cp ${jpg} calibration/; \
    done
    

    참고

    NVIDIA recommends at least 500 images to get a good accuracy. On this example, 1000 images are chosen to get better accuracy (more images = more accuracy). You can set it from head -1000. For example, for 2000 images, head -2000. This process can take a long time.

  6. 생성하기 calibration.txt 파일에 선택한 모든 이미지가 포함된

    realpath calibration/*jpg > calibration.txt
    
  7. 환경 변수 설정

    export INT8_CALIB_IMG_PATH=calibration.txt
    export INT8_CALIB_BATCH_SIZE=1
    

    참고

    INT8_CALIB_BATCH_SIZE 값이 높을수록 정확도가 높아지고 보정 속도가 빨라집니다. GPU 메모리에 맞게 설정하세요.

  8. 업데이트 config_infer_primary_yoloV8.txt 파일

    에서

    ...
    model-engine-file=model_b1_gpu0_fp32.engine
    #int8-calib-file=calib.table
    ...
    network-mode=0
    ...
    

    To

    ...
    model-engine-file=model_b1_gpu0_int8.engine
    int8-calib-file=calib.table
    ...
    network-mode=1
    ...
    

추론 실행

deepstream-app -c deepstream_app_config.txt

멀티스트림 설정

단일 딥스트림 애플리케이션에서 여러 스트림을 설정하려면 다음과 같이 딥스트림 애플리케이션을 변경하면 됩니다. deepstream_app_config.txt 파일

  1. 원하는 스트림 수에 따라 행과 열을 변경하여 그리드 표시를 만들 수 있습니다. 예를 들어 스트림이 4개인 경우 행 2개와 열 2개를 추가할 수 있습니다.

    [tiled-display]
    rows=2
    columns=2
    
  2. 설정 num-sources=4 를 클릭하고 uri 4개의 스트림 중

    [source0]
    enable=1
    type=3
    uri=<path_to_video>
    uri=<path_to_video>
    uri=<path_to_video>
    uri=<path_to_video>
    num-sources=4
    

추론 실행

deepstream-app -c deepstream_app_config.txt
멀티스트림 설정

벤치마크 결과

YOLOv8s 다음 표는 TensorRT 모델의 다양한 정밀도 수준(입력 크기 640x640)에서 NVIDIA Jetson Orin NX 16GB의 성능을 요약한 것입니다.

모델 이름정밀도추론 시간(ms/im)FPS
YOLOv8sFP3215.6364
FP167.94126
INT85.53181

감사

이 가이드는 시드 스튜디오의 친구인 락샨타와 일레인이 처음에 만들었습니다.

자주 묻는 질문

How do I set up Ultralytics YOLO11 on an NVIDIA Jetson device?

To set up Ultralytics YOLO11 on an NVIDIA Jetson device, you first need to install the DeepStream SDK compatible with your JetPack version. Follow the step-by-step guide in our Quick Start Guide to configure your NVIDIA Jetson for YOLO11 deployment.

What is the benefit of using TensorRT with YOLO11 on NVIDIA Jetson?

Using TensorRT with YOLO11 optimizes the model for inference, significantly reducing latency and improving throughput on NVIDIA Jetson devices. TensorRT provides high-performance, low-latency deep learning inference through layer fusion, precision calibration, and kernel auto-tuning. This leads to faster and more efficient execution, particularly useful for real-time applications like video analytics and autonomous machines.

Can I run Ultralytics YOLO11 with DeepStream SDK across different NVIDIA Jetson hardware?

Yes, the guide for deploying Ultralytics YOLO11 with the DeepStream SDK and TensorRT is compatible across the entire NVIDIA Jetson lineup. This includes devices like the Jetson Orin NX 16GB with JetPack 5.1.3 and the Jetson Nano 4GB with JetPack 4.6.4. Refer to the section DeepStream Configuration for YOLO11 for detailed steps.

How can I convert a YOLO11 model to ONNX for DeepStream?

To convert a YOLO11 model to ONNX format for deployment with DeepStream, use the utils/export_yoloV8.py 스크립트에서 DeepStream-Yolo 리포지토리에 저장합니다.

다음은 명령어 예시입니다:

python3 utils/export_yoloV8.py -w yolov8s.pt --opset 12 --simplify

모델 변환에 대한 자세한 내용은 모델 내보내기 섹션을 참조하세요.

What are the performance benchmarks for YOLO on NVIDIA Jetson Orin NX?

The performance of YOLO11 models on NVIDIA Jetson Orin NX 16GB varies based on TensorRT precision levels. For example, YOLOv8s models achieve:

  • FP32 정밀도: 15.63ms/im, 64 FPS
  • FP16 정밀도: 7.94ms/im, 126 FPS
  • INT8 정밀도: 5.53ms/im, 181 FPS

These benchmarks underscore the efficiency and capability of using TensorRT-optimized YOLO11 models on NVIDIA Jetson hardware. For further details, see our Benchmark Results section.

📅 Created 3 months ago ✏️ Updated 22 days ago

댓글