Yolo Tầm nhìn Thâm Quyến
Thâm Quyến
Tham gia ngay
Bảng chú giải thuật ngữ

TensorRT

Tối ưu hóa các mô hình học sâu với TensorRT để suy luận nhanh hơn, hiệu quả hơn NVIDIA GPU. Đạt được hiệu suất thời gian thực với YOLO và các ứng dụng AI.

TensorRT is a high-performance deep learning inference software development kit (SDK) developed by NVIDIA. It is designed to optimize neural network models for deployment, delivering low inference latency and high throughput for deep learning applications. By acting as an optimization compiler, TensorRT takes trained networks from popular frameworks like PyTorch and TensorFlow and restructures them to execute efficiently on NVIDIA GPUs. This capability is crucial for running complex AI models in production environments where speed and efficiency are paramount.

How TensorRT Optimizes Models

The core function of TensorRT is to convert a trained neural network into an optimized "engine" specifically tuned for the target hardware. It achieves this through several advanced techniques:

  • Layer Fusion: The optimizer combines multiple layers of a neural network into a single kernel, reducing memory access overhead and improving execution speed.
  • Precision Calibration: TensorRT supports reduced precision modes, such as mixed precision (FP16) and integer quantization (INT8). By reducing the number of bits used to represent numbers—often with minimal accuracy loss—developers can significantly accelerate math operations and reduce memory usage. This is a form of model quantization.
  • Kernel Auto-Tuning: The software automatically selects the best data layers and algorithms for the specific GPU architecture being used, ensuring maximum utilization of the hardware's parallel processing capabilities via CUDA.

Các Ứng dụng Thực tế

Nhờ khả năng xử lý lượng dữ liệu khổng lồ với độ trễ tối thiểu, TensorRT Nó được áp dụng rộng rãi trong các ngành công nghiệp dựa vào thị giác máy tính và các tác vụ trí tuệ nhân tạo phức tạp, nơi thời gian là yếu tố then chốt.

  1. Hệ thống tự hành: Trong lĩnh vực trí tuệ nhân tạo ứng dụng trong ô tô , xe tự lái phải xử lý nguồn cấp dữ liệu video từ nhiều camera để... detect Nhận diện người đi bộ, biển báo và chướng ngại vật ngay lập tức. Sử dụng TensorRT Các mô hình nhận thức như mạng phát hiện đối tượng có thể phân tích khung hình trong vòng mili giây, cho phép hệ thống điều khiển của xe đưa ra các quyết định quan trọng về an toàn mà không bị chậm trễ.
  2. Tự động hóa công nghiệp: Các nhà máy hiện đại sử dụng trí tuệ nhân tạo (AI) trong sản xuất để kiểm tra quang học tự động. Camera tốc độ cao chụp ảnh sản phẩm trên dây chuyền lắp ráp, và TensorRT - Các mô hình được tối ưu hóa giúp xác định các lỗi hoặc bất thường trong thời gian thực. Điều này đảm bảo rằng việc kiểm soát chất lượng theo kịp môi trường sản xuất tốc độ cao, thường được triển khai trên các thiết bị AI biên như nền tảng NVIDIA Jetson trực tiếp tại nhà máy.

Sử dụng TensorRT với Ultralytics YOLO

Tích hợp TensorRT vào quy trình làm việc của bạn một cách đơn giản với các công cụ AI hiện đại. ultralytics package provides a seamless method to convert standard PyTorch models into TensorRT engines. This allows users to leverage the state-of-the-art architecture of Ultralytics YOLO26 with the hardware acceleration of NVIDIA GPUs. For teams looking to manage their datasets and training pipelines before export, the Ultralytics Nền tảng offers a comprehensive environment to prepare models for such high-performance deployment.

Ví dụ sau đây minh họa cách xuất mô hình YOLO26 sang định dạng khác. TensorRT tệp động cơ (.engine) và sử dụng nó cho suy luận thời gian thực:

from ultralytics import YOLO

# Load the latest stable YOLO26 model (nano size)
model = YOLO("yolo26n.pt")

# Export the model to TensorRT format (creates 'yolo26n.engine')
# This step optimizes the computational graph for your specific GPU
model.export(format="engine")

# Load the optimized TensorRT engine for high-speed inference
trt_model = YOLO("yolo26n.engine")

# Run inference on an image source
results = trt_model("https://ultralytics.com/images/bus.jpg")

TensorRT vs. ONNX vs. Training Frameworks

It is important to distinguish TensorRT from other terms often heard in the model deployment landscape:

  • Vs. PyTorch/TensorFlow: Frameworks like PyTorch are primarily designed for model training and research, offering flexibility and ease of debugging. TensorRT is an inference engine designed solely for executing trained models as fast as possible. It is not used for training.
  • Vs. ONNX: The ONNX (Open Neural Network Exchange) format acts as an intermediary bridge between frameworks. While ONNX provides interoperability (e.g., moving a model from PyTorch to another platform), TensorRT focuses on hardware-specific optimization. Often, a model is converted to ONNX first, and then parsed by TensorRT to generate the final engine.

For developers aiming to maximize the performance of their AI agents or vision systems, understanding the transition from a training framework to an optimized runtime like TensorRT is a key step in professional MLOps.

Tham gia Ultralytics cộng đồng

Tham gia vào tương lai của AI. Kết nối, hợp tác và phát triển cùng với những nhà đổi mới toàn cầu

Tham gia ngay