Yolo Vision Shenzhen
Shenzhen
Iscriviti ora
Glossario

TensorRT

Ottimizzate i modelli di deep learning con TensorRT per un'inferenza più rapida ed efficiente sulle GPU NVIDIA . Ottenere prestazioni in tempo reale con YOLO e le applicazioni 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.

Applicazioni nel mondo reale

Grazie alla sua capacità di elaborare enormi quantità di dati con un ritardo minimo, TensorRT ampiamente adottato nei settori che si basano sulla visione artificiale e su complesse attività di intelligenza artificiale in cui la tempistica è fondamentale.

  1. Sistemi autonomi: nel campo dell' intelligenza artificiale nel settore automobilistico, le auto a guida autonoma devono elaborare i feed video provenienti da più telecamere per detect istantaneamente detect , segnali stradali e ostacoli. Utilizzando TensorRT, i modelli di percezione come le reti di rilevamento degli oggetti possono analizzare i fotogrammi in millisecondi, consentendo al sistema di controllo del veicolo di prendere decisioni critiche per la sicurezza senza ritardi.
  2. Automazione industriale: le fabbriche moderne utilizzano l'IA nella produzione per l'ispezione ottica automatizzata . Telecamere ad alta velocità catturano immagini dei prodotti sulle linee di assemblaggio e modelli TensorRT identificano difetti o anomalie in tempo reale. Ciò garantisce che il controllo qualità sia al passo con gli ambienti di produzione ad alta velocità , spesso implementando dispositivi IA edge come la piattaforma NVIDIA direttamente in fabbrica.

Utilizzo di TensorRT Ultralytics YOLO

L'integrazione di TensorRT nel flusso di lavoro è semplice con i moderni strumenti di IA. Il 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 Piattaforma Ultralytics offers a comprehensive environment to prepare models for such high-performance deployment.

L'esempio seguente mostra come esportare un modello YOLO26 in un file TensorRT (.engine) e utilizzarlo per inferenza in tempo reale:

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.

Unitevi alla comunità di Ultralytics

Entra nel futuro dell'AI. Connettiti, collabora e cresci con innovatori globali

Iscriviti ora