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/cu130 --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.13.0.dev (latest nightly)
  • CUDA 13.2 (CUDA 12.6 on Jetson)
  • TensorRT 11.0.0.114 (TensorRT 10.3 on Jetson)

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

torch_tensorrt_rtx-2.13.0-cp313-cp313-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.13Windows x86-64

torch_tensorrt_rtx-2.13.0-cp313-cp313-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

torch_tensorrt_rtx-2.13.0-cp312-cp312-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.12Windows x86-64

torch_tensorrt_rtx-2.13.0-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

torch_tensorrt_rtx-2.13.0-cp311-cp311-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.11Windows x86-64

torch_tensorrt_rtx-2.13.0-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

torch_tensorrt_rtx-2.13.0-cp310-cp310-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10Windows x86-64

torch_tensorrt_rtx-2.13.0-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

File details

Details for the file torch_tensorrt_rtx-2.13.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for torch_tensorrt_rtx-2.13.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0511debd3a1452e70c624387405ce5a07886f2be2eab6ac17d6f3a93759009f8
MD5 d75d32cfeee05c9de81635dd8b561666
BLAKE2b-256 48e61479c6f9e80c11b6d3cf47ca9a214e6d5e2bfb8eaee2b0cfbc4ef64c0984

See more details on using hashes here.

File details

Details for the file torch_tensorrt_rtx-2.13.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for torch_tensorrt_rtx-2.13.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4db3b6378274d5f526256f9b902b571b923544017d6eada5ac0414f816820d22
MD5 39252578b7dc05a92fbf839877f92250
BLAKE2b-256 d4aff422afc0139b137400a97bea52b337166d0bad252dddcbec79b4d2046146

See more details on using hashes here.

File details

Details for the file torch_tensorrt_rtx-2.13.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for torch_tensorrt_rtx-2.13.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 20a56035597eb1262e6ab60436b0a77810c869c6519c37b7b8662974fc087f6f
MD5 d34fe4326d1a10f7001ffe52b61bb6f3
BLAKE2b-256 f06f68227da72632b798255b7fa51b8c572d995ccd7f5b1589d5f96482511fa6

See more details on using hashes here.

File details

Details for the file torch_tensorrt_rtx-2.13.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for torch_tensorrt_rtx-2.13.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 20b0e05711b1db83e6dd7e366b0e4d24bce3f9572534c230a3ebd5c41ea55035
MD5 589538c29d4c289b68d9d40006d304c1
BLAKE2b-256 c849742d2294ad53acea8bef470ff13a422c04564b511ea97ced30b674923eed

See more details on using hashes here.

File details

Details for the file torch_tensorrt_rtx-2.13.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for torch_tensorrt_rtx-2.13.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d9453eb745a896bd29a3dc580431b6ee1281c4e5d068a8e05c0dfb4036194b0d
MD5 4acf111f1a8ac11bec96e79a2ea6b4ea
BLAKE2b-256 191ca56b43e69065ef83db24f8e4d4b73a0fdb70710aacce582d707f1dfe8689

See more details on using hashes here.

File details

Details for the file torch_tensorrt_rtx-2.13.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for torch_tensorrt_rtx-2.13.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ad06d02db56f9e7f2552d85a46c230d3590d40678e2123915f2816cd76635aad
MD5 6cda898bec4b7dc8f4cd545f70e6616b
BLAKE2b-256 bdc949a40706ab7e854271e046533483b8fceb86c9f43adb34397b08b6abfbee

See more details on using hashes here.

File details

Details for the file torch_tensorrt_rtx-2.13.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for torch_tensorrt_rtx-2.13.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a280020e719ac085aa3fa09c7f6b81f03b08d61e9bd952bbe7d8187aa938e0e5
MD5 43d9dc8f6c3b558b6a434245e984418b
BLAKE2b-256 ff9424c490a7c1b320626789cbb2ccd32510bc334017cfa8ca9cbe39c0118c35

See more details on using hashes here.

File details

Details for the file torch_tensorrt_rtx-2.13.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for torch_tensorrt_rtx-2.13.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4682195774d47eb153d3a2fbe94dbdd7c49f44b92f7b9b7ab9fab5256e59c6e6
MD5 083f65075602df03b9e978e39e0cf8fe
BLAKE2b-256 babfc6df420bac2604a3d1b8c906f8e82ad901b26e10ad1e2cd0f1d917bb6969

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.13.0 This release

8 files

2.12.1

8 files

2.12.0

8 files

2.11.0

8 files

0.0.1

1 file

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