ONNX Runtime vs TensorRT: Edge Server Latency & Throughput Guide
Benchmarking execution providers across NVIDIA Jetson Orin and edge micro-servers. Comparing kernel fusion, INT8 Post-Training Quantization (PTQ), dynamic shapes, and cold-start engine compilation.
TensorRT provides 25% to 45% lower latency than generic ONNX Runtime by compiling models into hardware-fused engine binaries with INT8 kernel auto-tuning. However, ONNX Runtime with the TensorRT Execution Provider bridges this gap to within 5% performance while preserving cross-hardware portability, dynamic shape flexibility, and automated fallback capabilities.
Empirical Benchmark: Jetson AGX Orin 64GB (Batch Size = 1 & 8)
Testing hardware: NVIDIA Jetson AGX Orin 64GB (275 TOPS, 60W Mode). JetPack 6.0, TensorRT 10.2, ONNX Runtime 1.19.
| Model & Precision | Standalone TensorRT | ORT + TensorRT EP | ORT + CUDA EP | Peak Memory (RSS) | TRT Advantage |
|---|---|---|---|---|---|
| YOLOv10-X (INT8, b=1) | 2.8 ms | 2.9 ms | 4.6 ms | 420 MB | +64% vs CUDA |
| CLIP-ViT-B/32 (FP16, b=1) | 4.1 ms | 4.3 ms | 6.8 ms | 680 MB | +58% vs CUDA |
| Llama-3.2-1B (W4A16, b=1) | 18.4 ms (TTFT) | 19.2 ms (TTFT) | 28.5 ms (TTFT) | 890 MB | +48% vs CUDA |
| Whisper-Base (FP16, b=4) | 14.2 ms | 15.0 ms | 24.6 ms | 510 MB | +64% vs CUDA |
1. The Execution Provider Hierarchy in ONNX Runtime
ONNX Runtime (ORT) abstracts physical hardware behind Execution Providers (EPs). When configured with TensorrtExecutionProvider, ORT analyzes the computational graph, extracts supported subgraphs, compiles them via the NVIDIA TensorRT builder, and falls back to CUDAExecutionProvider or CPUExecutionProvider for non-supported operators.
This hybrid approach eliminates the fatal runtime crashes that often occur when deploying pure TensorRT engines on models with exotic dynamic operators, while retaining up to 95% of peak TensorRT performance.
2. Production Pipeline: ORT with TensorRT EP & Engine Caching
To prevent multi-minute cold starts on edge reboots, always configure disk-backed engine caching and FP16/INT8 precision flags:
import onnxruntime as ort
import numpy as np
# Configure TensorRT Execution Provider options for edge server
trt_options = {
"device_id": 0,
"trt_fp16_enable": True,
"trt_int8_enable": False,
"trt_engine_cache_enable": True,
"trt_engine_cache_path": "/var/cache/tensorrt_engines",
"trt_max_workspace_size": 2147483648, # 2 GB workspace
"trt_builder_optimization_level": 3,
"trt_dump_ep_context_model": 1,
}
providers = [
("TensorrtExecutionProvider", trt_options),
("CUDAExecutionProvider", {"device_id": 0, "arena_extend_strategy": "kNextPowerOfTwo"}),
("CPUExecutionProvider", {}),
]
sess_options = ort.SessionOptions()
sess_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
sess_options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL
# Initialize session with auto-compilation and disk caching
session = ort.InferenceSession(
"/opt/models/llama3_2_1b_quant.onnx",
sess_options=sess_options,
providers=providers,
)
print("Active Execution Provider:", session.get_providers()[0]) 3. Architectural Decision Framework
Choose Standalone TensorRT When:
- • Deploying on fixed NVIDIA hardware with zero heterogeneous targets
- • Every single microsecond counts (real-time robotics, sub-5ms vision)
- • Batch inference is fully fixed with static dimensions
- • Your deployment pipeline has pre-compiled engine delivery
Choose ONNX Runtime (TRT EP) When:
- • Fleet consists of mixed hardware (NVIDIA GPUs, Intel CPUs, Apple NPUs)
- • Models contain dynamic shapes or unsupported custom layers
- • You require seamless fallback to CUDA or CPU on engine build failure
- • Engineering velocity and unified C#/Python/Rust bindings matter
Frequently Asked Questions: ONNX Runtime vs TensorRT
Q: Why is standalone TensorRT faster than default ONNX Runtime?
TensorRT performs target-specific kernel auto-tuning during its build phase, fusing multiple convolution, activation, and normalization layers into monolithic CUDA kernels that minimize global GPU memory read/write cycles.
Q: What is the overhead of using ONNX Runtime with TensorrtExecutionProvider?
Empirical profiling demonstrates that ONNX Runtime with TensorrtExecutionProvider incurs only 3% to 6% latency overhead compared to pure TensorRT C++ APIs, primarily due to tensor memory descriptor conversions between ONNX and TensorRT engine buffers.
Q: How does engine caching improve cold-start latency on edge servers?
Compiling a model into a TensorRT execution plan can take several minutes on edge hardware like NVIDIA Jetson. Enabling trt_engine_cache_enable serializes the optimized plan file to disk, reducing subsequent cold-starts from 180 seconds down to under 450 milliseconds.