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-2.13.0-cp313-cp313-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.13Windows x86-64

torch_tensorrt-2.13.0-cp313-cp313-manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

torch_tensorrt-2.13.0-cp313-cp313-manylinux_2_28_aarch64.whl (3.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

torch_tensorrt-2.13.0-cp312-cp312-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.12Windows x86-64

torch_tensorrt-2.13.0-cp312-cp312-manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

torch_tensorrt-2.13.0-cp312-cp312-manylinux_2_28_aarch64.whl (3.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

torch_tensorrt-2.13.0-cp311-cp311-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.11Windows x86-64

torch_tensorrt-2.13.0-cp311-cp311-manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

torch_tensorrt-2.13.0-cp311-cp311-manylinux_2_28_aarch64.whl (3.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

torch_tensorrt-2.13.0-cp310-cp310-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.10Windows x86-64

torch_tensorrt-2.13.0-cp310-cp310-manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

torch_tensorrt-2.13.0-cp310-cp310-manylinux_2_28_aarch64.whl (3.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

File details

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

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6a9289494a938b3b552753f1a4755ac9e0129d6cfe580da25da1b4a0b0e52d5c
MD5 b39ae83fc46d9e5ab13eab81e49cb611
BLAKE2b-256 5a8a1bc391249267e531e96254ce3aa487220c3ca101ce562d11c978d9e9dc15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ba653ebe1d47b85107c84c1a084403a88eb94d63d6fd68ad5194f04c6bc1db72
MD5 c0594a2426c7e04dedae1e08f555bb79
BLAKE2b-256 203fa2e9c67f13147a2330e8127b74ccfa7bd5c78b5783b045d210c182155562

See more details on using hashes here.

File details

Details for the file torch_tensorrt-2.13.0-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3c14762f19888f3c694ba8e0e7decc3faeae3129b5939add78cdb71ecfc731d2
MD5 55abfe026b98486e71647f31ebb0a83a
BLAKE2b-256 71064cc297e91e14549705491090c368075fd68df866f1db64e9eb8b5c5a0427

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d7367cd1b65de376a5b6c2d19024472f8ab4155a301da95330d24b465ead32ee
MD5 b81bf67e1ebc3b5eae9b2033ca0d1809
BLAKE2b-256 93ab227001b98f40cd035dbb88a356ac2747ab32140d5f212639e6ed749bef24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 29fec6b0ed9715c689e87aded68cec2d400cfef000417f804be3e523deb08b32
MD5 19a9c733aaf516213f50ca6b796c804e
BLAKE2b-256 78192041f20f679cd933fdff75ec3de8374329f1a02eb13ce82a40f825f8aa8d

See more details on using hashes here.

File details

Details for the file torch_tensorrt-2.13.0-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e095a71c9f6eef7cb356d9daf2b02621bd4e2ad1afda6784c56dc12ba5d8f269
MD5 ce6b071e98c9fb82769861341b7a21ae
BLAKE2b-256 7e9b8eff1d7332da84205c83e22f9077d8950db29041687bb3a8025828a54b98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d8579d85f1c1f8d5c58554b5fb0c852fc88bd745534c5b49d3ea05814f114342
MD5 e6a2927d56d4b218600b3d00e71024ab
BLAKE2b-256 fc3b1355fba6dd640572e7609fe518843072b93c08d6a8c8c0a712d319e4c68c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 91b0cc45e4c1d7612b31a556116f01868393c3d7fdec97c6a703aef74335911c
MD5 7c32d9d0f9bb95586878fac4941202e4
BLAKE2b-256 95d87e873f377023e0e819c2a4f8422376c09dd5d14c287a562b295a7124e378

See more details on using hashes here.

File details

Details for the file torch_tensorrt-2.13.0-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a4e09145b60395a73f781cc913834eb83d3e43fce447e676422bf1c8315fdf5a
MD5 a9a1e05c8a293dd0b2f7597eecdf7b38
BLAKE2b-256 644fed88d166546c0ba1253b40aa7b64e5c0e1cf68255e2140133f327ae50537

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f2887cc69d1ec01eef0154c9f67e00579c65f4a6916555f69b2f546eeb12758b
MD5 01c78b9bcab7122bce3b1cb352c23cf7
BLAKE2b-256 246961cd47ad7cfa61fe9f142ee94aef75833d46d19b0ac7896f7e2a24e64a53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a13407f8d3cdcf0f2f6954adb9a46e33a591f36da2b0fd3413e81d1ffac7cdf0
MD5 aaada26e373c5d8051dc3f802c74c184
BLAKE2b-256 6e6566496ee9cf216931e4ed6d975d5969eb2f33143a8be63dd8f64a28e3a953

See more details on using hashes here.

File details

Details for the file torch_tensorrt-2.13.0-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for torch_tensorrt-2.13.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4c764a6800159694899c0edc7d049baf99b49dbf3b3562a2d2be0bcce26b3e00
MD5 3abda76e38414be31001a7af77731396
BLAKE2b-256 8ed14731429ee87c8d9483f61cdff3b5a1e84f7cc93ffbeca8d3118584e2d9f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page