稳定版依赖的 PyTorch/CUDA/TensorRT 版本需与 README 标注匹配,否则不保证测试通过;Windows 平台只支持 Dynamo 路径;Jetson 需自行源码编译,不能直接装 wheel。
TensorRT
pytorchBSD-3-Clause活跃维护把 PyTorch、TorchScript 和 FX 模型编译成 TensorRT 引擎,在 NVIDIA GPU 上做推理加速,省去手写 TensorRT 网络的麻烦。
PyTorch/TorchScript/FX compiler for NVIDIA GPUs using TensorRT
pip install torch-tensorrt需要 NVIDIA GPU 与 CUDA 环境(README 标注 CUDA 13.4、TensorRT 11.4.0.106);支持 Linux AMD64、Linux SBSA、Windows(仅 Dynamo)以及 JetPack-4.4+ 的 Jetson(需源码编译);README 未给出具体显存要求。
把 TensorRT 接进 PyTorch 的编译器,一行代码让 NVIDIA GPU 上的推理提速
把 PyTorch、TorchScript 和 FX 模型编译成 TensorRT 引擎,在 NVIDIA GPU 上做推理加速,省去手写 TensorRT 网络的麻烦。
核心能力
- 用 torch.compile 的 tensorrt 后端一行接入
- 支持 AOT 导出并序列化为 ExportedProgram 或 TorchScript
- 导出的 TorchScript 可在无 Python 的 libtorch C++ 环境部署
- 覆盖 Dynamo 与 FX 前端编译 PyTorch 模型
- 支持 FP8 量化推理与 Hugging Face LLM 编译
容易踩的坑
- v2.14.0Torch-TensorRT v2.14.0最新正式版2026-09-10 · 2026-09-10 05:39 UTC
Torch-TensorRT 2.14.0 Linux x86-64 and Windows targets
PyTorch 2.14, CUDA 12.6/13.0/13.2, TensorRT 11.1, Python 3.10~3.14
Torch-TensorRT Wheels are available:
x86-64 Linux and Windows: CUDA 13.2 + Python 3.10-3.14 + Torch 2.14 + TensorRT 11.1
- Available via PyPI: https://pypi.org/project/torch-tensorrt
CUDA 12.6/13.0/13.2 + Python 3.10-3.14 + Torch 2.14 + TensorRT 11.1
- Available via PyTorch index: https://download.pytorch.org/whl/torch-tensorrt
aarch64 SBSA Linux and Jetson Thor and Orin: CUDA 13.2 + Python 3.10-3.14 + Torch 2.14 + TensorRT 11.1
- Available via PyPI: https://pypi.org/project/torch-tensorrt
CUDA 13.0/13.2 + Python 3.10-3.14 + Torch 2.14 + TensorRT 11.1
- Available via PyTorch index: https://download.pytorch.org/whl/torch-tensorrt
Torch-TensorRT-RTX 2.14.0 Linux x86-64 and Windows targets
PyTorch 2.14, CUDA 12.6/13.0/13.2, TensorRT-RTX 1.6, Python 3.10~3.14
Torch-TensorRT-RTX Wheels are available:
x86-64 Linux and Windows: CUDA 13.2 + Python 3.10-3.14 + Torch 2.14 + TensorRT 11.1
- Available via PyPI: https://pypi.org/project/torch-tensorrt-rtx
CUDA 12.6/13.0/13.2 + Python 3.10-3.14 + Torch 2.14 + TensorRT 11.1
- Available via PyTorch index: https://download.pytorch.org/whl/torch-tensorrt-rtx
Torch-TensorRT-Executorch-Runtime 2.14.0 Linux x86-64 and Windows targets
PyTorch 2.14, CUDA 12.6/13.0/13.2, TensorRT 11.1, Python 3.10~3.14
Torch-TensorRT-Executorch-Runtime Wheels are available:
x86-64 Linux: CUDA 13.2 + Python 3.10-3.14 + Torch 2.14 + TensorRT 11.1
- Available via PyPI: https://pypi.org/project/torch-tensorrt-executorch-runtime
CUDA 12.6/13.0/13.2 + Python 3.10-3.14 + Torch 2.14 + TensorRT 11.1
- Available via PyTorch index: https://download.pytorch.org/whl/torch-tensorrt-executorch-runtime
aarch64 SBSA Linux and Jetson Thor and Orin: CUDA 13.2 + Python 3.10-3.14 + Torch 2.14 + TensorRT 11.1
- Available via PyPI: https://pypi.org/project/torch-tensorrt-executorch-runtime
CUDA 12.6/13.0/13.2 + Python 3.10-3.14 + Torch 2.14 + TensorRT 11.1
- Available via PyTorch index: https://download.pytorch.org/whl/torch-tensorrt-executorch-runtime
New Features:
Executorch
Torch-TensorRT 2.14 expands its ExecuTorch integration with a more complete export and deployment workflow for TensorRT-accelerated .pte models.
Highlights:
- New torch_tensorrt.executorch.export() API for producing an inspectable EdgeProgramManager before serialization.
- Support for exporting multiple named methods into a single .pte artifact, with optional constant methods and ETRecord generation for debugging.
- torch_tensorrt.save(..., output_format="executorch") remains the streamlined path for one-step model export.
- Supports composing the TensorRT partitioner with additional ExecuTorch partitioners, enabling mixed TensorRT and CUDA delegation in one artifact.
- The optional torch-tensorrt-executorch-runtime package enables loading and running exported .pte files through torch_tensorrt.load(..., format="executorch").
- Continues to use the lightweight native TensorRT ExecuTorch backend, without a Torch or LibTorch dependency at deployment time.
- Aliased I/O for in-place operations — TensorRT engines can now write directly into a caller-owned or module-owned tensor's storage, so KV-cache updates in streaming and autoregressive inference no longer pay a full cache-sized copy at the engine boundary.
- Multiple optimization profiles — A single engine can now carry several independently tuned shape profiles selected at runtime by index or automatically, so bimodal workloads like LLM prefill and decode each get kernels tuned for their own shapes instead of splitting the difference.
ExecuTorch support is currently available on Linux(x86-64+aarch64), will Support Windows from 2.15 release.
Multi-Device in TRT-RTX
This release expands multi-GPU support across standard TensorRT a
- v2.13.0Torch-TensorRT v2.13.02026-07-28 · 2026-07-28 21:52 UTC
查看更新说明
Torch-TensorRT 2.13.0 Linux x86-64 and Windows targets
PyTorch 2.13, CUDA 13.0/13.2, TensorRT 11.0, Python 3.10~3.13
Torch-TensorRT Wheels are available:
x86-64 Linux and Windows: CUDA 13.0/13.2 + Python 3.10-3.13 is Available via PyPI
- https://pypi.org/project/torch-tensorrt/
- Available via PyTorch index: https://download.pytorch.org/whl/torch-tensorrt
aarch64 SBSA Linux and Jetson Thor and Orin: CUDA 13.0/13.2 + Python 3.10–3.13 + Torch 2.13 + TensorRT 11.0
- Available via PyPI: https://pypi.org/project/torch-tensorrt/
- Available via PyTorch index: https://download.pytorch.org/whl/torch-tensorrt
Torch-TensorRT-RTX 2.13.0 Linux x86-64 and Windows targets
PyTorch 2.13, CUDA 13.0/13.2, TensorRT-RTX 1.5, Python 3.10~3.13
Torch-TensorRT-RTX Wheels are available:
x86-64 Linux and Windows: CUDA 13.0/13.2 + Python 3.10-3.13 is Available via PyPI
CUDA 13.0/13.2 + Python 3.10-3.13 is also Available via Pytorch Index
New Features:
GQA/MQA and Decode-Phase Attention Support
Extends Group Query Attention (GQA) and Multi-Query Attention (MQA) alongside traditional Multi-Head Attention (MHA), enabling efficient inference for modern large language models. This release relaxes SDPA validator constraints to allow variable head-count configurations, adds native support for decode-phase attention where query and key sequences differ, and introduces comprehensive HLO-level test coverage across all three attention kernel variants (standard, flash, efficient) with multiple precision levels (fp16, bf16, fp32). These changes unlock optimized inference patterns for LLMs using GQA/MQA while maintaining full backward compatibility with existing MHA-based models.
FP8 Attention Quantization Support
Supports FP8 quantization of the attention in both TensorRT's IAttention path and decomposed attention path (decompose_attention=True). Working with NVIDIA ModelOpt, it detects when attention inputs (Q, K, V) are quantized to FP8 and configures TensorRT's native FP8 MHA kernel for optimal performance on FP8-capable hardware (Hopper and newer GPUs). A ViT quantization example demonstrates both IAttention and decomposed attention paths.
Caller-Selected CUDA Streams and Green Context Support
Enables TensorRT inference on caller-selected CUDA streams across both Torch-TensorRT and ExecuTorch. The PyTorch runtime now respects active non-default streams, while ExecuTorch introduces a scoped CudaStreamGuard API. This supports CUDA Green Contexts, NCCL streams, and custom GPU scheduling without changing default-stream behavior. CUDA Graphs are recaptured when streams change, and completion events safely protect asynchronous execution-context reuse.
TensorRT 11 Support
Torch-TensorRT 2.13 adds support for NVIDIA TensorRT 11, with release packages updated to TensorRT 11.0. The integration has been updated for TensorRT 11 APIs across compilation, runtime execution, packaging, and distributed inference. Highlights:
- TensorRT 11.0 support for Python and C++ workflows.
- Updated CUDA 12 and CUDA 13 package dependencies for TensorRT 11.
- Updated distributed and NCCL-based operators for TensorRT 11.
- Improved scaled dot-product attention accuracy using TensorRT 11 fixes.
- Updated build configurations, CI coverage, and prebuilt release artifacts for TensorRT 11. TensorRT 11 is the default supported TensorRT version for Torch-TensorRT 2.13 release packages.
ExecuTorch Support
This release delivers a pure ExecuTorch TensorRT backend for deploying TensorRT-accelerated models in ExecuTorch .pte format. The native runtime path no longer depends on Torch or LibTorch, enabling lightweight C++ deployment using only ExecuTorch and TensorRT runtime components. Users can continue exporting TensorRT-compiled ExportedProgram and FX models with: torch_tenso
- v2.12.1Torch-TensorRT v2.12.12026-06-09 · 2026-06-09 23:56 UTC
查看更新说明
Torch-TensorRT 2.12.1 Linux x86-64 and Windows targets
PyTorch 2.12, CUDA 13.0, TensorRT 10.16, Python 3.10~3.13
Torch-TensorRT Wheels are available:
x86-64 Linux and Windows: CUDA 13.0 + Python 3.10-3.13 is Available via PyPI
aarch64 SBSA Linux and Jetson Thor CUDA 13.0 + Python 3.10–3.13 + Torch 2.12 + TensorRT 10.16
- Available via PyPI: https://pypi.org/project/torch-tensorrt/
- Available via PyTorch index: https://download.pytorch.org/whl/torch-tensorrt
Jetson Orin
- no torch_tensorrt 2.9/2.10/2.11/2.12 release for Jetson Orin
- please continue using torch_tensorrt 2.8 release
Torch-TensorRT-RTX 2.12.1 Linux x86-64 and Windows targets
PyTorch 2.12, CUDA 13.0, TensorRT-RTX 1.4, Python 3.10~3.13
Torch-TensorRT-RTX Wheels are available:
x86-64 Linux and Windows: CUDA 13.0 + Python 3.10-3.13 is Available via PyPI
CUDA 13.0 + Python 3.10-3.13 is also Available via Pytorch Index
What's Changed
- release 2.12 MD TRT fix by @apbose in https://github.com/pytorch/TensorRT/pull/4291
- fix: cap tensorrt_rtx requirement below 1.5.0 on release/2.12 by @tp5uiuc in https://github.com/pytorch/TensorRT/pull/4298
- fix(lowering): use factored sqrt form for complex acosh rewrite by @tp5uiuc in https://github.com/pytorch/TensorRT/pull/4300
- setup_nccl_for_torch_tensorrt change by @apbose in https://github.com/pytorch/TensorRT/pull/4303
Full Changelog: https://github.com/pytorch/TensorRT/compare/v2.12.0...v2.12.1
- v2.12.0Torch-TensorRT v2.12.02026-05-20 · 2026-05-20 19:24 UTC
查看更新说明
Torch-TensorRT 2.12.0 Linux x86-64 and Windows targets
PyTorch 2.12, CUDA 13.0, TensorRT 10.16, Python 3.10~3.13
Torch-TensorRT Wheels are available:
x86-64 Linux and Windows: CUDA 13.0 + Python 3.10-3.13 is Available via PyPI
aarch64 SBSA Linux and Jetson Thor CUDA 13.0 + Python 3.10–3.13 + Torch 2.12 + TensorRT 10.16
- Available via PyPI: https://pypi.org/project/torch-tensorrt/
- Available via PyTorch index: https://download.pytorch.org/whl/torch-tensorrt
Jetson Orin
- no torch_tensorrt 2.9/2.10/2.11/2.12 release for Jetson Orin
- please continue using torch_tensorrt 2.8 release
Torch-TensorRT-RTX 2.12.0 Linux x86-64 and Windows targets
PyTorch 2.12, CUDA 13.0, TensorRT-RTX 1.4, Python 3.10~3.13
Torch-TensorRT-RTX Wheels are available:
x86-64 Linux and Windows: CUDA 13.0 + Python 3.10-3.13 is Available via PyPI
CUDA 13.0 + Python 3.10-3.13 is also Available via Pytorch Index
Native Distributed Collectives
In prior versions of Torch-TensorRT, distributed operators were backed by kernels provided by TensorRT-LLM that the user needed to manually install. With Torch-TensorRT 2.12, many of these operations are natively supported which means in deployment, only Torch-TensorRT needs to be installed.
The distributed infrastructure is designed to operate on top of
torch.distributed. Once a graph is sharded, traced and compiled. The torch.distributed device mesh can be passed to torch-tensorrt compiled modules using the following API:trt_model = torch.compile(model, backend="torch_tensorrt", ...) _ = trt_model(inp) # warmup — triggers engine build dist.barrier() with torch_tensorrt.distributed.distributed_context(dist.group.WORLD, trt_model) as dmodel: output = dmodel(inp) dist.destroy_process_group() os._exit(0)This can be done at compile time as well
with torch_tensorrt.distributed.distributed_context(tp_group): trt_model = torch.compile(model, backend="torch_tensorrt", ...) output = trt_model(inp)Note:
use_distributed_traceis no longer necessary to compile multi-device models, torch-tensorrt will automatically recognize distributed collectives and set the setting for the user.torchtrtrun
The distributed operations utilize the NCCL version distributed by PyTorch which must be added to LD_PRELOAD before importing torch-tensorrt. As a convience we provide a tool
torchtrtrunwhich is analogous totorchrunthat configures these libraries correctly in addition to allowing users to launch models distributed across multiple nodes.For example:
# Node 0 (rank 0): torchtrtrun --nproc_per_node=1 --nnodes=2 --node_rank=0 \ --rdzv_endpoint=<node0-ip>:29500 \ tensor_parallel_llama_multinode.py # Node 1 (rank 1): torchtrtrun --nproc_per_node=1 --nnodes=2 --node_rank=1 \ --rdzv_endpoint=<node0-ip>:29500 \ tensor_parallel_llama_multinode.pySerialization and torch.export
Models sharded and then exported can be compiled and saved to disk before being loaded on a deployment system. By default these modules attempt to bind to the default torch distributed device mesh. If there are multiple valid device meshes availble, the above API can be used to set a specific one to execute the engine.
More information on torch-tensorrt distributed collective support can be found here: https://docs.pytorch.org/TensorRT/tutorials/deployment/distributed_inference.html#multinode-inference
More information on native multi-device collectives can be found here: https://docs.nvidia.com/deeplearning/tensorrt/latest/inference-library/work-with-transformers.html#multi-device-attention-preview-feature
ExecuTorch Support
Torch-TensorRT 2.12 introduces initial ExecuTorch integration for exporting and ru
- v2.11.0Torch-TensorRT v2.11.02026-04-07 · 2026-04-07 17:03 UTC
查看更新说明
Torch-TensorRT 2.11.0 Linux x86-64 and Windows targets
PyTorch 2.11, CUDA 12.6 12.8 12.9, 13.0, TensorRT 10.15, Python 3.10~3.13
Torch-TensorRT Wheels are available:
x86-64 Linux and Windows: CUDA 13.0 + Python 3.10-3.13 is Available via PyPI
CUDA 12.6/12.8/12.9/13.0 + Python 3.10-3.13 is also Available via Pytorch Index
aarch64 SBSA Linux and Jetson Thor CUDA 13.0 + Python 3.10–3.13 + Torch 2.11 + TensorRT 10.15
- Available via PyPI: https://pypi.org/project/torch-tensorrt/
- Available via PyTorch index: https://download.pytorch.org/whl/torch-tensorrt
Jetson Orin
- no torch_tensorrt 2.9/2.10/2.11 release for Jetson Orin
- please continue using torch_tensorrt 2.8 release
Torch-TensorRT-RTX 2.11.0 Linux x86-64 and Windows targets
PyTorch 2.11, CUDA 12.9, 13.0, TensorRT-RTX 1.3, Python 3.10~3.13
Torch-TensorRT-RTX Wheels are available:
x86-64 Linux and Windows: CUDA 13.0 + Python 3.10-3.13 is Available via PyPI
CUDA 12.9/13.0 + Python 3.10-3.13 is also Available via Pytorch Index
note: tensorrt-rtx 1.3 wheel is not in pypi yet, so please download the tarball from https://developer.nvidia.com/tensorrt-rtx install the wheel from tarball
IAttention Layer
In this release, TensorRT's native IAttention layer is used by default to handle various attention-related ATen ops, including SDPA, Flash-SDPA, Efficient-SDPA, and cuDNN-SDPA. This integration enables more efficient execution and can improve model performance. To explicitly enable this behavior, set
decompose_attention=Falsein thecompile()function. When enabled, the native TensorRT implementation is utilized to achieve optimized attention computation. However, due to current TensorRT limitations, certain operations such ascompute_log_sumexpandGrouped Query Attention (GQA)are not yet supported. If these cases are encountered, an informational prompt will be displayed during compilation. Alternatively, you can setdecompose_attention=Trueto decompose the attention ops into multiple basic ATen ops. Although this approach may not achieve the same level of performance optimization, it offers broader operator coverage and greater compatibility across different model architectures.Improvements to the Symbolic Shape System
Two key improvements have been made to the symbolic shape system used to track mutations on dynamic dimensions through out the body of the graph.
- A shape prop formula is recorded as metadata in for every compiled engine.
Now instead of needing to instantiate the engine in order to do key tasks like serialization, retracing or similar tasks which require fake tensor propagation, we record the shape relation between inputs and outputs for every TRT subgraph at compile time and store it as metadata. The
torch.ops.tensorrt.execute_enginemeta kernel now just replays this function in the new shape environment. This should enable more seamless integration with the rest of the torch.compile ecosystem as meta kernels in Torch-TensorRT will now work in the same way as other meta kernels.- For unbounded shape ranges, we now select sane defaults
Dynamic shapes are lazily inserted into Dynamo graphs. This is most noticeable when using Torch-TensorRT as a backend for
torch.compile. Here when the first inference call is made to a boxed functiontrt_mod = torch.compile(mod, backend="tensorrt") trt_mod(*inputs)The shapes of intermediate tensors are considered static and derived eagerly from the shapes of input tensors.
If input shapes then change
trt_mod(*other_sized_inputs)TorchDynamo will start marking dimensions where shapes differ as dynamic dimensions. However, it does not assume upper bounds and criticall
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Torch-TensorRT
Torch-TensorRT brings the power of TensorRT to PyTorch. Accelerate inference latency by up to 5x compared to eager execution in just one line of code.
Installation
Stable versions of Torch-TensorRT are published on PyPI
pip install torch-tensorrt
Nightly versions of Torch-TensorRT are published on the PyTorch package index
pip install --pre torch-tensorrt --index-url https://download.pytorch.org/whl/nightly/cu134 --extra-index-url https://pypi.org/simple
Torch-TensorRT is also distributed in the ready-to-run NVIDIA NGC PyTorch Container which has all dependencies with the proper versions and example notebooks included.
For more advanced installation methods, please see here
Quickstart
Option 1: torch.compile
You can use Torch-TensorRT anywhere you use torch.compile:
import torch
import torch_tensorrt
model = MyModel().eval().cuda() # define your model here
x = torch.randn((1, 3, 224, 224)).cuda() # define what the inputs to the model will look like
optimized_model = torch.compile(model, backend="tensorrt")
optimized_model(x) # compiled on first run
optimized_model(x) # this will be fast!
Option 2: Export
If you want to optimize your model ahead-of-time and/or deploy in a C++ environment, Torch-TensorRT provides an export-style workflow that serializes an optimized module. This module can be deployed in PyTorch or with libtorch (i.e. without a Python dependency).
Step 1: Optimize + serialize
import torch
import torch_tensorrt
model = MyModel().eval().cuda() # define your model here
inputs = [torch.randn((1, 3, 224, 224)).cuda()] # define a list of representative inputs here
trt_gm = torch_tensorrt.compile(model, ir="dynamo", inputs=inputs)
torch_tensorrt.save(trt_gm, "trt.ep", inputs=inputs) # PyTorch only supports Python runtime for an ExportedProgram. For C++ deployment, use a TorchScript file
torch_tensorrt.save(trt_gm, "trt.ts", output_format="torchscript", inputs=inputs)
Step 2: Deploy
Deployment in PyTorch:
import torch
import torch_tensorrt
inputs = [torch.randn((1, 3, 224, 224)).cuda()] # your inputs go here
# You can run this in a new python session!
model = torch.export.load("trt.ep").module()
# model = torch_tensorrt.load("trt.ep").module() # this also works
model(*inputs)
Deployment in C++:
#include "torch/script.h"
#include "torch_tensorrt/torch_tensorrt.h"
auto trt_mod = torch::jit::load("trt.ts");
auto input_tensor = [...]; // fill this with your inputs
auto results = trt_mod.forward({input_tensor});
Further resources
- Double PyTorch Inference Speed for Diffusion Models Using Torch-TensorRT
- Up to 50% faster Stable Diffusion inference with one line of code
- Optimize LLMs from Hugging Face with Torch-TensorRT
- Run your model in FP8 with Torch-TensorRT
- Accelerated Inference in PyTorch 2.X with Torch-TensorRT
- Tools to resolve graph breaks and boost performance [coming soon]
- Tech Talk (GTC '23)
- Documentation
Platform Support
| Platform | Support |
|---|---|
| Linux AMD64 / GPU | Supported |
| Linux SBSA / GPU | Supported |
| Windows / GPU | Supported (Dynamo only) |
| Linux Jetson / GPU | Source Compilation Supported on JetPack-4.4+ |
| Linux Jetson / DLA | Source Compilation Supported on JetPack-4.4+ |
| Linux ppc64le / GPU | Not supported |
Note: Refer NVIDIA L4T PyTorch NGC container for PyTorch libraries on JetPack.
Dependencies
These are the following dependencies used to verify the testcases. Torch-TensorRT can work with other versions, but the tests are not guaranteed to pass.
- Bazel 8.1.1
- Libtorch 2.16.0.dev (latest nightly)
- CUDA 13.4
- TensorRT 11.4.0.106
Deprecation Policy
Deprecation is used to inform developers that some APIs and tools are no longer recommended for use. Beginning with version 2.3, Torch-TensorRT has the following deprecation policy:
Deprecation notices are communicated in the Release Notes. Deprecated API functions will have a statement in the source documenting when they were deprecated. Deprecated methods and classes will issue deprecation warnings at runtime, if they are used. Torch-TensorRT provides a 6-month migration period after the deprecation. APIs and tools continue to work during the migration period. After the migration period ends, APIs and tools are removed in a manner consistent with semantic versioning.
Contributing
Take a look at the CONTRIBUTING.md
License
The Torch-TensorRT license can be found in the LICENSE file. It is licensed with a BSD Style licence