Registry / ai-ml / torch-tensorrt

torch-tensorrt

JSON →
library2.12.0pypypiunverified

Torch-TensorRT is a compiler for PyTorch/TorchScript models targeting NVIDIA TensorRT. Version 2.12.0 supports Python 3.10+. It automatically optimizes models for inference on NVIDIA GPUs. Release cadence roughly quarterly.

pip install torch-tensorrt
INSTALL
IMPORT
SIG · TORCH-TENSORRT
T
torch-tensorrt
ai-mlpythonv2.12.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

torch_tensorrt
import torch_tensorrt
import torchtrt
Old alias used before 1.4.0; no longer works
torch.jit
import torch
TorchScript usage does not require separate import

Compile a PyTorch model using Torch-TensorRT with default settings.

import torch import torch_tensorrt model = torch.nn.Linear(10, 5).eval().cuda() inputs = torch.randn(1, 10).cuda() traced_model = torch.jit.trace(model, inputs) optimized_model = torch_tensorrt.compile( traced_model, inputs=[inputs], enabled_precisions={torch.float32} ) print(optimized_model(inputs))
Debug
Known issues
breakingWith Torch-TensorRT >= 2.0, the `torch.jit.script` path is deprecated and may be removed. Use `torch.jit.trace` or `torch_tensorrt.compile()` directly with torch.nn.Module.
fix
Use `torch.jit.trace` or pass module directly to `torch_tensorrt.compile` with `ir="torch_script"` or `ir="dynamo"`.
affects: >=2.0.0
deprecatedThe import `torchtrt` (underscore-less) is deprecated since version 1.4.0 and will be removed in a future release.
fix
Replace `import torchtrt` with `import torch_tensorrt`.
affects: >=1.4.0
gotchaPrecision specification changed. `enabled_precisions` argument takes a `set` of `torch.dtype` (e.g., `{torch.float32}`), not strings. In older versions you used strings like `'fp32'`.
fix
Use `torch.dtype` values in the set: `{torch.float32, torch.float16}`.
affects: >=2.0.0
gotchaWhen using TensorRT 10.x, Torch-TensorRT may require a specific minor version. Mismatch can cause runtime errors like 'CUDNN_STATUS_NOT_SUPPORTED'.
fix
Check compatibility matrix in official docs. Install `tensorrt` via `nvidia-tensorrt` pip package or use Docker containers.
affects: >=2.10.0
Upgrade
Version history
2.12.0latest on PyPI · released May 20, 2026
Audit
Dependencies
torchrequiredCore dependency; must be compatible version
tensorrtoptionalTensorRT runtime libraries (often via nvidia-tensorrt pip package)
Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources
torch-tensorrt — pip install torch-tensorrt · libregistry