Skip to main content

Torch-TensorRT

Easily achieve the best inference performance for any PyTorch model on the NVIDIA platform.

Documentation pytorch cuda trt license Linux x86-64 Nightly Wheels Linux SBSA Nightly Wheels Windows Nightly Wheels


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

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.15.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

Metadata

Release files for torch-tensorrt 2.15.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for torch-tensorrt 2.15.0
File Actions
torch_tensorrt-2.15.0-1-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for torch_tensorrt-2.15.0-1-cp314-cp314-win_amd64.whl
torch_tensorrt-2.15.0-1-cp314-cp314-manylinux_2_39_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.39+ ARM64 Details for torch_tensorrt-2.15.0-1-cp314-cp314-manylinux_2_39_aarch64.whl
torch_tensorrt-2.15.0-1-cp314-cp314-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64 Details for torch_tensorrt-2.15.0-1-cp314-cp314-manylinux_2_28_x86_64.whl
torch_tensorrt-2.15.0-1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for torch_tensorrt-2.15.0-1-cp313-cp313-win_amd64.whl
torch_tensorrt-2.15.0-1-cp313-cp313-manylinux_2_39_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.39+ ARM64 Details for torch_tensorrt-2.15.0-1-cp313-cp313-manylinux_2_39_aarch64.whl
torch_tensorrt-2.15.0-1-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details for torch_tensorrt-2.15.0-1-cp313-cp313-manylinux_2_28_x86_64.whl
torch_tensorrt-2.15.0-1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for torch_tensorrt-2.15.0-1-cp312-cp312-win_amd64.whl
torch_tensorrt-2.15.0-1-cp312-cp312-manylinux_2_39_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.39+ ARM64 Details for torch_tensorrt-2.15.0-1-cp312-cp312-manylinux_2_39_aarch64.whl
torch_tensorrt-2.15.0-1-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details for torch_tensorrt-2.15.0-1-cp312-cp312-manylinux_2_28_x86_64.whl
torch_tensorrt-2.15.0-1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for torch_tensorrt-2.15.0-1-cp311-cp311-win_amd64.whl
torch_tensorrt-2.15.0-1-cp311-cp311-manylinux_2_39_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.39+ ARM64 Details for torch_tensorrt-2.15.0-1-cp311-cp311-manylinux_2_39_aarch64.whl
torch_tensorrt-2.15.0-1-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details for torch_tensorrt-2.15.0-1-cp311-cp311-manylinux_2_28_x86_64.whl

Total release size: 47.4 MB

Release files / torch_tensorrt-2.15.0-1-cp314-cp314-win_amd64.whl

Download URL torch_tensorrt-2.15.0-1-cp314-cp314-win_amd64.whl
Size 2.6 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
a456d900c53a6dac7aed726c06cb8ef09617a222d8dd4c7aca0f2fc0de3b0142
BLAKE2b-256 checksum
How to use checksums
87fc0718c39d51054b299174339b891b9feb25b77dda20754f2ef15f4c333275
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / torch_tensorrt-2.15.0-1-cp314-cp314-manylinux_2_39_aarch64.whl

Download URL torch_tensorrt-2.15.0-1-cp314-cp314-manylinux_2_39_aarch64.whl
Size 4.6 MB
Tags CPython 3.14 Linux glibc 2.39+ ARM64
SHA-256 checksum
How to use checksums
57a648b0ce81cb2289b3f20c6f894463a2d5199882454a2562fb6a877216bb69
BLAKE2b-256 checksum
How to use checksums
7d34126f6681b8f385a7f2c75bf937b120cc0e5bda6ade4d729d6a56dabe0e58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / torch_tensorrt-2.15.0-1-cp314-cp314-manylinux_2_28_x86_64.whl

Download URL torch_tensorrt-2.15.0-1-cp314-cp314-manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ed656dcaed5110ea44495c7a30779e6fad5da9d91911403a999ffc09cd4a18d7
BLAKE2b-256 checksum
How to use checksums
30e9e0bac00bbb284b74d0dedce87203b5d334f35e9306f8e2bb6d3a28649c46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / torch_tensorrt-2.15.0-1-cp313-cp313-win_amd64.whl

Download URL torch_tensorrt-2.15.0-1-cp313-cp313-win_amd64.whl
Size 2.6 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
ea22981ecd7168e489bbbfaf78d78847a91a9f1f81e38830ad78f4d48044b322
BLAKE2b-256 checksum
How to use checksums
41f71ea5b6e3cf86019e56c9d39ea86844d42e6eafc872c92502a6c2600e1b60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / torch_tensorrt-2.15.0-1-cp313-cp313-manylinux_2_39_aarch64.whl

Download URL torch_tensorrt-2.15.0-1-cp313-cp313-manylinux_2_39_aarch64.whl
Size 4.6 MB
Tags CPython 3.13 Linux glibc 2.39+ ARM64
SHA-256 checksum
How to use checksums
ff088698d8ac9f3f8a9f890be6a540a9fead929ccc2cacbd64e216f6e3cff1f9
BLAKE2b-256 checksum
How to use checksums
31aba658a61b9cf438f991c1c9a024a619eed0d1d28fb68659f4396f33661b6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / torch_tensorrt-2.15.0-1-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL torch_tensorrt-2.15.0-1-cp313-cp313-manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
67c564dbf792f1fa736e1195e007922d2bcfbc6c45fd356f31b7703484056473
BLAKE2b-256 checksum
How to use checksums
c8916dccb4b66e329dc6184bebef1e9d6b178e37b26e14a20b92424eea2e1403
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / torch_tensorrt-2.15.0-1-cp312-cp312-win_amd64.whl

Download URL torch_tensorrt-2.15.0-1-cp312-cp312-win_amd64.whl
Size 2.6 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
55ed93be14a5c1a8b726b65ee7fbc6e976cd935ce5947706a5ca269b110473ca
BLAKE2b-256 checksum
How to use checksums
0d9c8aac4e4fc28d47e3ae5872ee1d6e6c610fda225aba3d17c17e0f50601417
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / torch_tensorrt-2.15.0-1-cp312-cp312-manylinux_2_39_aarch64.whl

Download URL torch_tensorrt-2.15.0-1-cp312-cp312-manylinux_2_39_aarch64.whl
Size 4.6 MB
Tags CPython 3.12 Linux glibc 2.39+ ARM64
SHA-256 checksum
How to use checksums
611941a40226b02011e17acdbf56329ad8d85bca7877eb9defc9548f32f49ada
BLAKE2b-256 checksum
How to use checksums
1be79b3bf2f9ae5818db09e714cc2e9c56b0972c5621bfc8e66ffebd397a7978
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / torch_tensorrt-2.15.0-1-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL torch_tensorrt-2.15.0-1-cp312-cp312-manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
1ce4e44b46ac1767bba4fdd1d6542192a76e8e9ac0acd6f00ea1c85abe3377dd
BLAKE2b-256 checksum
How to use checksums
064a825b58dd07b07f8dafefb36a7d8eba85eab3d7b0a8303824f0723dbef894
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / torch_tensorrt-2.15.0-1-cp311-cp311-win_amd64.whl

Download URL torch_tensorrt-2.15.0-1-cp311-cp311-win_amd64.whl
Size 2.6 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
b6cc836dabc9a9446f3fe8d0ef95680b9fd6823633d0448672547bf236b64f9a
BLAKE2b-256 checksum
How to use checksums
02e2f04abb50c3fe2eae21473d75b5e02ac496b22b45c41a9f244546f959659f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / torch_tensorrt-2.15.0-1-cp311-cp311-manylinux_2_39_aarch64.whl

Download URL torch_tensorrt-2.15.0-1-cp311-cp311-manylinux_2_39_aarch64.whl
Size 4.6 MB
Tags CPython 3.11 Linux glibc 2.39+ ARM64
SHA-256 checksum
How to use checksums
e7e649b62dbc12e8919a3c9b5066d784f6b49500fb63885f3ab2d2ce59d43b3e
BLAKE2b-256 checksum
How to use checksums
901c53f044346542ae53a05bbcdacbffa398cfa2d6b6973f7ea58775e420c277
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / torch_tensorrt-2.15.0-1-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL torch_tensorrt-2.15.0-1-cp311-cp311-manylinux_2_28_x86_64.whl
Size 4.7 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
56fb0668e5da9e5a26718ce75ca1dddfa74522ea4231610314b807c1b08ae87e
BLAKE2b-256 checksum
How to use checksums
d1583c63037fdc83c080ce4167e1da4c2c20d5c1a4898113633e6801ef772d28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Security for torch-tensorrt 2.15.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page