diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ac0c05c015..9f754c915d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,8 @@ repos: - id: check-yaml - id: trailing-whitespace - id: check-added-large-files + args: + - --maxkb=1000 - id: check-vcs-permalinks - id: check-merge-conflict - id: mixed-line-ending diff --git a/docs/_cpp_api/class_view_hierarchy.html b/docs/_cpp_api/class_view_hierarchy.html index cd545e89c3..3930617583 100644 --- a/docs/_cpp_api/class_view_hierarchy.html +++ b/docs/_cpp_api/class_view_hierarchy.html @@ -1,603 +1,699 @@ + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - Class Hierarchy — Torch-TensorRT master documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to content - -
- + +
+
+
+ + + + + + + + + + + + + + + + +
+ + + + +
-
- Torch-TensorRT + +
+ Shortcuts
-
-
- - -
-
- -
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
-

- Class Hierarchy - - ¶ - -

-
-
-
-
-
-
- - - + + - + \ No newline at end of file diff --git a/docs/_cpp_api/classtorch__tensorrt_1_1DataType.html b/docs/_cpp_api/classtorch__tensorrt_1_1DataType.html index 015842191b..787604e11a 100644 --- a/docs/_cpp_api/classtorch__tensorrt_1_1DataType.html +++ b/docs/_cpp_api/classtorch__tensorrt_1_1DataType.html @@ -9,22 +9,22 @@ - - Class DataType — Torch-TensorRT master documentation - - - - - + Class DataType — Torch-TensorRT v1.3.0 documentation + + + + + + + + + + + - - - - - @@ -36,11 +36,11 @@ - + - - + + @@ -196,9 +196,9 @@ - - + + - +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
@@ -526,19 +527,43 @@

Resources

-
+ + @@ -520,19 +521,43 @@

Resources

-
+ + - +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
+ + + + + + + + + + + + + + + + +
+
+
+ + + + + + + + + + + + + + + + +
+ + + + +
+
+ +
+ Shortcuts +
+
+ +
+
+ + + +
+ +
+
+ +
+

Full API

+
+

Namespaces

+ + + + +
+
+

Classes and Structs

+ + + + + + + + +
+
+

Enums

+ + +
+
+

Functions

+ + + + + + + + + + + + + + + + +
+
+

Defines

+ + + + + + + + +
+
+ + +
+ +
+
+ + + + +
+ + + +
+

+ © Copyright 2022, NVIDIA Corporation. + +

+
+ +
+ Built with Sphinx using a theme provided by Read the Docs. +
+ + +
+ +
+
+ +
+
+
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+

Docs

+

Access comprehensive developer documentation for PyTorch

+ View Docs +
+ +
+

Tutorials

+

Get in-depth tutorials for beginners and advanced developers

+ View Tutorials +
+ +
+

Resources

+

Find development resources and get your questions answered

+ View Resources +
+
+
+
+ + + + - +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
-

2acf632451c2482b8eee3d1e461fb6c5

+

df1b2a8a92ce4f9fab463924bf8d335d

Torch-TensorRT Getting Started - CitriNet

@@ -1422,7 +1434,7 @@

FP16 (half precision)

What’s next

-

Now it’s time to try Torch-TensorRT on your own model. Fill out issues at https://github.com/pytorch/TensorRT. Your involvement will help future development of Torch-TensorRT.

+

Now it’s time to try Torch-TensorRT on your own model. Fill out issues at https://github.com/NVIDIA/Torch-TensorRT. Your involvement will help future development of Torch-TensorRT.

[ ]:
 
@@ -1441,15 +1453,6 @@

What’s next - - - - - - -

- @@ -1459,7 +1462,7 @@

What’s next

- © Copyright 2021, NVIDIA Corporation. + © Copyright 2022, NVIDIA Corporation.

@@ -1586,19 +1589,43 @@

Resources

-
+ + -

783b2cf2fc5d4e06a7736325633fdd88

+

0d3b5ad697c6475f968fdb3988a8493a

Torch-TensorRT Getting Started - EfficientNet-B0

@@ -1132,7 +1144,7 @@

FP16 (half precision)

What’s next

-

Now it’s time to try Torch-TensorRT on your own model. If you run into any issues, you can fill them at https://github.com/pytorch/TensorRT. Your involvement will help future development of Torch-TensorRT.

+

Now it’s time to try Torch-TensorRT on your own model. If you run into any issues, you can fill them at https://github.com/NVIDIA/Torch-TensorRT. Your involvement will help future development of Torch-TensorRT.

[ ]:
 
@@ -1151,15 +1163,6 @@

What’s next - - - - - - -

- @@ -1169,7 +1172,7 @@

What’s next

- © Copyright 2021, NVIDIA Corporation. + © Copyright 2022, NVIDIA Corporation.

@@ -1296,19 +1299,43 @@

Resources

-
+ + -

2e8a7944f7a54c9a93c9656fc33a0ab3

+

8895119d8f634fe5b8ca2b679a440289

Masked Language Modeling (MLM) with Hugging Face BERT Transformer

@@ -1055,7 +1067,7 @@

Contents

What’s next

-

Now it’s time to try Torch-TensorRT on your own model. If you run into any issues, you can fill them at https://github.com/pytorch/TensorRT. Your involvement will help future development of Torch-TensorRT.

+

Now it’s time to try Torch-TensorRT on your own model. If you run into any issues, you can fill them at https://github.com/NVIDIA/Torch-TensorRT. Your involvement will help future development of Torch-TensorRT.

[ ]:
 
@@ -1074,15 +1086,6 @@

What’s next - - - - - - -

- @@ -1092,7 +1095,7 @@

What’s next

- © Copyright 2021, NVIDIA Corporation. + © Copyright 2022, NVIDIA Corporation.

@@ -1213,19 +1216,43 @@

Resources

-
+ + -

fdd5160d4757402ea245c7fbb8dc0f03

+

b3fd7c0e57b74b66bc0d32c2be7cdcb4

Torch-TensorRT Getting Started - ResNet 50

@@ -1351,7 +1363,7 @@

FP16 (half precision)

What’s next

-

Now it’s time to try Torch-TensorRT on your own model. If you run into any issues, you can fill them at https://github.com/pytorch/TensorRT. Your involvement will help future development of Torch-TensorRT.

+

Now it’s time to try Torch-TensorRT on your own model. If you run into any issues, you can fill them at https://github.com/NVIDIA/Torch-TensorRT. Your involvement will help future development of Torch-TensorRT.

@@ -1362,15 +1374,6 @@

What’s next - - - - - - - - @@ -1380,7 +1383,7 @@

What’s next

- © Copyright 2021, NVIDIA Corporation. + © Copyright 2022, NVIDIA Corporation.

@@ -1507,19 +1510,43 @@

Resources

-
+ +

+

Setting up the model

In this section, we will: * Get sample data. * Download model from torch hub. * Build simple utility functions

@@ -1144,7 +1139,7 @@

Build simple utility functions

+

Working with Dynamic shapes in Torch TRT

-

Enabling “Dynamic Shaped” tensors to be used is essentially enabling the ability to defer defining the shape of tensors until run-time. Torch TensorRT simply leverages TensorRT’s Dynamic shape support. You can read more about TensorRT’s implementation in the TensorRT Documentation.

-

To make use of dynamic shapes, you need to provide three shapes: * min_shape: The minimum size of the tensor considered for optimizations. * opt_shape: The optimizations will be done in an effort to maximize performance for this shape. * max_shape: The maximum size of the tensor considered for optimizations.

-

Generally, users can expect the best performance within the specified ranges. Performance for other shapes maybe be lower for other shapes (depending on the model ops and GPU used)

-

In the following example, we will showcase varying batch sizes, which is the zeroth dimension of our input tensors. As Convolution operations require that the channel dimension be a build-time constant, we won’t be changing the sizes of other channels in this example, but for models which contain ops conducive to changes in other channels, this functionality can be freely used.

+

Enabling “Dynamic Shaped” tensors to be used is essentially enabling the ability to defer defining the shape of tensors until runetime. Torch TensorRT simply leverages TensorRT’s Dynamic shape support. You can read more about TensorRT’s implementation in the TensorRT Documentation.

+

To make use of dynamic shapes, you need to provide three shapes: * min_shape: The minimum size of the tensor considered for optimizations. * opt_shape: The optimizations will be done with an effort to maximize performance for this shape. * min_shape: The maximum size of the tensor considered for optimizations.

+

Generally, users can expect best performance within the specified ranges. Performance for other shapes may be be lower for other shapes (depending on the model ops and GPU used)

+

In the following example, we will showcase varing batch size, which is the zeroth dimension of our input tensors. As Convolution operations require that the channel dimension be a build-time constant, we won’t be changing sizes of other channels in this example, but for models which contain ops conducive to changes in other channels, this functionality can be freely used.

[11]:
 
@@ -1456,15 +1452,6 @@

What’s Next? - - - - - - -

- @@ -1474,7 +1461,7 @@

What’s Next?

- © Copyright 2021, NVIDIA Corporation. + © Copyright 2022, NVIDIA Corporation.

@@ -1494,7 +1481,6 @@

What’s Next?

@@ -1201,15 +1213,6 @@

What’s next - - - - - - - - @@ -1219,7 +1222,7 @@

What’s next

- © Copyright 2021, NVIDIA Corporation. + © Copyright 2022, NVIDIA Corporation.

@@ -1351,19 +1354,43 @@

Resources

-
+ + -

aa77691fd7754170ac652a03d651d0b9

+

6c149d85c6314d4ea59e4ea603d757b7

Object Detection with Torch-TensorRT (SSD)


@@ -770,8 +782,8 @@

Contents

--++ @@ -779,8 +791,8 @@

Single Shot MultiBox Detector model for object detection

- + +

_

alt

alt

alt

image1

@@ -1316,15 +1328,6 @@

References - - - - - - - - @@ -1334,7 +1337,7 @@

References

- © Copyright 2021, NVIDIA Corporation. + © Copyright 2022, NVIDIA Corporation.

@@ -1468,19 +1471,43 @@

Resources

-
+ + - + + - +
    @@ -712,7 +712,7 @@

    Resources

  • Ecosystem
  • - +
  • Mobile
  • @@ -774,7 +774,7 @@

    Resources

  • Resources
  • - +
    • diff --git a/docs/contributors/conversion.html b/docs/contributors/conversion.html index 1002914f0f..6b3d8ede08 100644 --- a/docs/contributors/conversion.html +++ b/docs/contributors/conversion.html @@ -9,22 +9,22 @@ - - Conversion Phase — Torch-TensorRT master documentation - - - - - + Conversion Phase — Torch-TensorRT v1.3.0 documentation + + + + + + + + + + + - - - - - @@ -36,11 +36,11 @@ - + - - + + @@ -196,9 +196,9 @@ - - + +
    • YouTube
    • LinkedIn
    • -
    +
- +
    @@ -632,7 +632,7 @@

    Resources

  • Ecosystem
  • - +
  • Mobile
  • @@ -694,7 +694,7 @@

    Resources

  • Resources
  • - +
    • diff --git a/docs/contributors/lowering.html b/docs/contributors/lowering.html index 2fae41eb4e..ef6d209687 100644 --- a/docs/contributors/lowering.html +++ b/docs/contributors/lowering.html @@ -9,22 +9,22 @@ - - Lowering Phase — Torch-TensorRT master documentation - - - - - + Lowering Phase — Torch-TensorRT v1.3.0 documentation + + + + + + + + + + + - - - - - @@ -36,11 +36,11 @@ - + - - + + @@ -196,9 +196,9 @@ - - + +
    • YouTube
    • LinkedIn
    • -
    +
- +
    @@ -794,7 +794,7 @@

    Resources

  • Ecosystem
  • - +
  • Mobile
  • @@ -856,7 +856,7 @@

    Resources

  • Resources
  • - +
    • diff --git a/docs/contributors/partitioning.html b/docs/contributors/partitioning.html index 9a16db9373..22ac24334a 100644 --- a/docs/contributors/partitioning.html +++ b/docs/contributors/partitioning.html @@ -9,22 +9,22 @@ - - Partitioning Phase — Torch-TensorRT master documentation - - - - - + Partitioning Phase — Torch-TensorRT v1.3.0 documentation + + + + + + + + + + + - - - - - @@ -36,11 +36,11 @@ - + - - + + @@ -196,9 +196,9 @@ - - + +
    • YouTube
    • LinkedIn
    • -
    +
- +
- +
    @@ -600,7 +600,7 @@

    Resources

  • Ecosystem
  • - +
  • Mobile
  • @@ -662,7 +662,7 @@

    Resources

  • Resources
  • - +
    • diff --git a/docs/contributors/runtime.html b/docs/contributors/runtime.html index e3d4bd35d0..36ce583c99 100644 --- a/docs/contributors/runtime.html +++ b/docs/contributors/runtime.html @@ -9,22 +9,22 @@ - - Runtime Phase — Torch-TensorRT master documentation - - - - - + Runtime Phase — Torch-TensorRT v1.3.0 documentation + + + + + + + + + + + - - - - - @@ -36,11 +36,11 @@ - + - - + + @@ -196,9 +196,9 @@ - - + +
    • YouTube
    • LinkedIn
    • -
    +
- +
    @@ -652,7 +652,7 @@

    Resources

  • Ecosystem
  • - +
  • Mobile
  • @@ -714,7 +714,7 @@

    Resources

  • Resources
  • - +
    • diff --git a/docs/contributors/system_overview.html b/docs/contributors/system_overview.html index f70c4da833..6ef6afc4eb 100644 --- a/docs/contributors/system_overview.html +++ b/docs/contributors/system_overview.html @@ -9,22 +9,22 @@ - - System Overview — Torch-TensorRT master documentation - - - - - + System Overview — Torch-TensorRT v1.3.0 documentation + + + + + + + + + + + - - - - - @@ -36,11 +36,11 @@ - + - - + + @@ -196,9 +196,9 @@ - - + +
    +
- +
    @@ -636,7 +636,7 @@

    Resources

  • Ecosystem
  • - +
  • Mobile
  • @@ -698,7 +698,7 @@

    Resources

  • Resources
  • - +
    • diff --git a/docs/contributors/useful_links.html b/docs/contributors/useful_links.html index 561907acdf..b4c643d96b 100644 --- a/docs/contributors/useful_links.html +++ b/docs/contributors/useful_links.html @@ -9,22 +9,22 @@ - - Useful Links for Torch-TensorRT Development — Torch-TensorRT master documentation - - - - - + Useful Links for Torch-TensorRT Development — Torch-TensorRT v1.3.0 documentation + + + + + + + + + + + - - - - - @@ -36,11 +36,11 @@ - + - - + + @@ -196,9 +196,9 @@ - - + +
    • YouTube
    • LinkedIn
    • -
    +
- +
    @@ -617,7 +617,7 @@

    Resources

  • Ecosystem
  • - +
  • Mobile
  • @@ -679,7 +679,7 @@

    Resources

  • Resources
  • - +
    • diff --git a/docs/contributors/writing_converters.html b/docs/contributors/writing_converters.html index 709ab9683b..1b77a05a1f 100644 --- a/docs/contributors/writing_converters.html +++ b/docs/contributors/writing_converters.html @@ -9,22 +9,22 @@ - - Writing Converters — Torch-TensorRT master documentation - - - - - + Writing Converters — Torch-TensorRT v1.3.0 documentation + + + + + + + + + + + - - - - - @@ -36,11 +36,11 @@ - + - - + + @@ -196,9 +196,9 @@ - - + +
    • YouTube
    • LinkedIn
    • -
    +
- +
    @@ -707,7 +707,7 @@

    Resources

  • Ecosystem
  • - +
  • Mobile
  • @@ -769,7 +769,7 @@

    Resources

  • Resources
  • - +
    • diff --git a/docs/genindex.html b/docs/genindex.html index e2e1e2c9a3..e33ef579c2 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -6,24 +6,24 @@ - + - - Index — Torch-TensorRT master documentation - - - - - + Index — Torch-TensorRT v1.3.0 documentation + + + + + + + + + + + - - - - - @@ -33,11 +33,11 @@ - + - - + + @@ -193,9 +193,9 @@ - - + +

-
-

Building using cuDNN & TensorRT tarball distributions

-
-

This is recommended so as to build Torch-TensorRT hermetically and insures any compilation errors are not caused by version issues

-

Make sure when running Torch-TensorRT that these versions of the libraries are prioritized in your $LD_LIBRARY_PATH

-
-
-
You need to download the tarball distributions of TensorRT and cuDNN from the NVIDIA website.
-
-
-

Place these files in a directory (the directories third_party/distdir/[x86_64-linux-gnu | aarch64-linux-gnu] exist for this purpose)

-

Then compile referencing the directory with the tarballs

-
-

If you get errors regarding the packages, check their sha256 hashes and make sure they match the ones listed in WORKSPACE

-
-
-

Release Build

-
bazel build //:libtorchtrt -c opt --distdir third_party/distdir/[x86_64-linux-gnu | aarch64-linux-gnu]
-
-
-

A tarball with the include files and library can then be found in bazel-bin

-
-
-

Debug Build

-

To build with debug symbols use the following command

-
bazel build //:libtorchtrt -c dbg --distdir third_party/distdir/[x86_64-linux-gnu | aarch64-linux-gnu]
-
-
-

A tarball with the include files and library can then be found in bazel-bin

-
-
-

Pre CXX11 ABI Build

-

To build using the pre-CXX11 ABI use the pre_cxx11_abi config

-
bazel build //:libtorchtrt --config pre_cxx11_abi -c [dbg/opt] --distdir third_party/distdir/[x86_64-linux-gnu | aarch64-linux-gnu]
-
-
-

A tarball with the include files and library can then be found in bazel-bin

-
-
-
-

Building using locally installed cuDNN & TensorRT

-
-

If you encounter bugs and you compiled using this method please disclose that you used local sources in the issue (an ldd dump would be nice too)

-
-

Install TensorRT, CUDA and cuDNN on the system before starting to compile.

-

In WORKSPACE comment out:

-
# Downloaded distributions to use with --distdir
+recommended commands:
+       

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ PyTorch Source +

+
+

+ Recommended C++ Compilation Command +

+
+

+ Recommended Python Compilation Command +

+
+

+ PyTorch whl file from PyTorch.org +

+
+

+ bazel build //:libtorchtrt -c opt –config pre_cxx11_abi +

+
+

+ python3 setup.py bdist_wheel +

+
+

+ libtorch-shared-with-deps- + + + * + + + .zip from PyTorch.org +

+
+

+ bazel build //:libtorchtrt -c opt –config pre_cxx11_abi +

+
+

+ python3 setup.py bdist_wheel +

+
+

+ libtorch-cxx11-abi-shared-with-deps- + + + * + + + .zip from PyTorch.org +

+
+

+ bazel build //:libtorchtrt -c opt +

+
+

+ python3 setup.py bdist_wheel –use-cxx11-abi +

+
+

+ PyTorch preinstalled in an NGC container +

+
+

+ bazel build //:libtorchtrt -c opt +

+
+

+ python3 setup.py bdist_wheel –use-cxx11-abi +

+
+

+ PyTorch from the NVIDIA Forums for Jetson +

+
+

+ bazel build //:libtorchtrt -c opt +

+
+

+ python3 setup.py bdist_wheel –jetpack-version 4.6 –use-cxx11-abi +

+
+

+ PyTorch built from Source +

+
+

+ bazel build //:libtorchtrt -c opt +

+
+

+ python3 setup.py bdist_wheel –use-cxx11-abi +

+
+
+
+

+ NOTE: For all of the above cases you must correctly declare the source of PyTorch you intend to use in your WORKSPACE file for both Python and C++ builds. See below for more information +

+
+
+

+ You then have two compilation options: +

+ + +

+ + Building using cuDNN & TensorRT tarball distributions + + + ¶ + +

+
+
+

+ This is recommended so as to build Torch-TensorRT hermetically and insures any compilation errors are not caused by version issues +

+

+ Make sure when running Torch-TensorRT that these versions of the libraries are prioritized in your + + + $LD_LIBRARY_PATH + + +

+
+
+
+
+ You need to download the tarball distributions of TensorRT and cuDNN from the NVIDIA website. +
+
+ +
+
+

+ Place these files in a directory (the directories + + + third_party/distdir/[x86_64-linux-gnu + + + | + + + aarch64-linux-gnu] + + + exist for this purpose) +

+

+ Then compile referencing the directory with the tarballs +

+
+
+

+ If you get errors regarding the packages, check their sha256 hashes and make sure they match the ones listed in + + + WORKSPACE + + +

+
+
+

+ Release Build + + ¶ + +

+
+
+
bazel build //:libtorchtrt -c opt --distdir third_party/distdir/[x86_64-linux-gnu | aarch64-linux-gnu]
+
+
+
+

+ A tarball with the include files and library can then be found in + + + bazel-bin + + +

+ + +

+ Debug Build + + ¶ + +

+

+ To build with debug symbols use the following command +

+
+
+
bazel build //:libtorchtrt -c dbg --distdir third_party/distdir/[x86_64-linux-gnu | aarch64-linux-gnu]
+
+
+
+

+ A tarball with the include files and library can then be found in + + + bazel-bin + + +

+

+ Pre CXX11 ABI Build + + ¶ + +

+

+ To build using the pre-CXX11 ABI use the + + + pre_cxx11_abi + + + config +

+
+
+
bazel build //:libtorchtrt --config pre_cxx11_abi -c [dbg/opt] --distdir third_party/distdir/[x86_64-linux-gnu | aarch64-linux-gnu]
+
+
+
+

+ A tarball with the include files and library can then be found in + + + bazel-bin + + +

+ + +

+ + Building using locally installed cuDNN & TensorRT + + + ¶ + +

+
+
+

+ If you encounter bugs and you compiled using this method please disclose that you used local sources in the issue (an ldd dump would be nice too) +

+
+
+

+ Install TensorRT, CUDA and cuDNN on the system before starting to compile. +

+

+ In WORKSPACE comment out: +

+
+
+
# Downloaded distributions to use with --distdir
 http_archive(
-    name = "cudnn",
-    urls = ["<URL>",],
+    name = "cudnn",
+    urls = ["<URL>",],
 
-    build_file = "@//third_party/cudnn/archive:BUILD",
-    sha256 = "<TAR SHA256>",
-    strip_prefix = "cuda"
+    build_file = "@//third_party/cudnn/archive:BUILD",
+    sha256 = "<TAR SHA256>",
+    strip_prefix = "cuda"
 )
 
 http_archive(
-    name = "tensorrt",
-    urls = ["<URL>",],
+    name = "tensorrt",
+    urls = ["<URL>",],
 
-    build_file = "@//third_party/tensorrt/archive:BUILD",
-    sha256 = "<TAR SHA256>",
-    strip_prefix = "TensorRT-<VERSION>"
+    build_file = "@//third_party/tensorrt/archive:BUILD",
+    sha256 = "<TAR SHA256>",
+    strip_prefix = "TensorRT-<VERSION>"
 )
-
-
-

and uncomment

-
# Locally installed dependencies
+
+
+
+

+ and uncomment +

+
+
+
# Locally installed dependencies
 new_local_repository(
-    name = "cudnn",
-    path = "/usr/",
-    build_file = "@//third_party/cudnn/local:BUILD"
+    name = "cudnn",
+    path = "/usr/",
+    build_file = "@//third_party/cudnn/local:BUILD"
 )
 
 new_local_repository(
-name = "tensorrt",
-path = "/usr/",
-build_file = "@//third_party/tensorrt/local:BUILD"
+name = "tensorrt",
+path = "/usr/",
+build_file = "@//third_party/tensorrt/local:BUILD"
 )
-
-
-
-

Release Build

-

Compile using:

-
bazel build //:libtorchtrt -c opt
-
-
-

A tarball with the include files and library can then be found in bazel-bin

-
-
-

Debug Build

-

To build with debug symbols use the following command

-
bazel build //:libtorchtrt -c dbg
-
-
-

A tarball with the include files and library can then be found in bazel-bin

-
-
-

Pre CXX11 ABI Build

-

To build using the pre-CXX11 ABI use the pre_cxx11_abi config

-
bazel build //:libtorchtrt --config pre_cxx11_abi -c [dbg/opt]
-
-
-
-
-
-

Building the Python package

-

Begin by installing ninja

-

You can build the Python package using setup.py (this will also build the correct version of libtorchtrt.so)

-
python3 setup.py [install/bdist_wheel]
-
-
-
-

Debug Build

-
python3 setup.py develop [--user]
-
-
-

This also compiles a debug build of libtorchtrt.so

-
-
-
-

Building Natively on aarch64 (Jetson)

-
-

Prerequisites

-

Install or compile a build of PyTorch/LibTorch for aarch64

-

NVIDIA hosts builds the latest release branch for Jetson here:

-
-
-
-
-

Enviorment Setup

-

To build natively on aarch64-linux-gnu platform, configure the WORKSPACE with local available dependencies.

-
    -
  1. Disable the rules with http_archive for x86_64 by commenting the following rules:

  2. -
-
#http_archive(
-#    name = "libtorch",
-#    build_file = "@//third_party/libtorch:BUILD",
-#    strip_prefix = "libtorch",
-#    urls = ["https://download.pytorch.org/libtorch/cu102/libtorch-cxx11-abi-shared-with-deps-1.5.1.zip"],
-#    sha256 = "cf0691493d05062fe3239cf76773bae4c5124f4b039050dbdd291c652af3ab2a"
+
+
+
+

+ Release Build + + ¶ + +

+

+ Compile using: +

+
+
+
bazel build //:libtorchtrt -c opt
+
+
+
+

+ A tarball with the include files and library can then be found in + + + bazel-bin + + +

+ + +

+ Debug Build + + ¶ + +

+

+ To build with debug symbols use the following command +

+
+
+
bazel build //:libtorchtrt -c dbg
+
+
+
+

+ A tarball with the include files and library can then be found in + + + bazel-bin + + +

+

+ Pre CXX11 ABI Build + + ¶ + +

+

+ To build using the pre-CXX11 ABI use the + + + pre_cxx11_abi + + + config +

+
+
+
bazel build //:libtorchtrt --config pre_cxx11_abi -c [dbg/opt]
+
+
+
+

+ + Building the Python package + + + ¶ + +

+

+ Begin by installing + + + ninja + + +

+

+ You can build the Python package using + + + setup.py + + + (this will also build the correct version of + + + libtorchtrt.so + + + ) +

+
+
+
python3 setup.py [install/bdist_wheel]
+
+
+
+

+ Debug Build + + ¶ + +

+
+
+
python3 setup.py develop [--user]
+
+
+
+

+ This also compiles a debug build of + + + libtorchtrt.so + + +

+

+ + Building Natively on aarch64 (Jetson) + + + ¶ + +

+

+ Prerequisites + + ¶ + +

+

+ Install or compile a build of PyTorch/LibTorch for aarch64 +

+

+ NVIDIA hosts builds the latest release branch for Jetson here: +

+
+ +
+

+ Enviorment Setup + + ¶ + +

+

+ To build natively on aarch64-linux-gnu platform, configure the + + + WORKSPACE + + + with local available dependencies. +

+
    +
  1. +

    + Disable the rules with + + + http_archive + + + for x86_64 by commenting the following rules: +

    +
  2. +
+
+
+
#http_archive(
+#    name = "libtorch",
+#    build_file = "@//third_party/libtorch:BUILD",
+#    strip_prefix = "libtorch",
+#    urls = ["https://download.pytorch.org/libtorch/cu102/libtorch-cxx11-abi-shared-with-deps-1.5.1.zip"],
+#    sha256 = "cf0691493d05062fe3239cf76773bae4c5124f4b039050dbdd291c652af3ab2a"
 #)
 
 #http_archive(
-#    name = "libtorch_pre_cxx11_abi",
-#    build_file = "@//third_party/libtorch:BUILD",
-#    strip_prefix = "libtorch",
-#    sha256 = "818977576572eadaf62c80434a25afe44dbaa32ebda3a0919e389dcbe74f8656",
-#    urls = ["https://download.pytorch.org/libtorch/cu102/libtorch-shared-with-deps-1.5.1.zip"],
+#    name = "libtorch_pre_cxx11_abi",
+#    build_file = "@//third_party/libtorch:BUILD",
+#    strip_prefix = "libtorch",
+#    sha256 = "818977576572eadaf62c80434a25afe44dbaa32ebda3a0919e389dcbe74f8656",
+#    urls = ["https://download.pytorch.org/libtorch/cu102/libtorch-shared-with-deps-1.5.1.zip"],
 #)
 
 # Download these tarballs manually from the NVIDIA website
 # Either place them in the distdir directory in third_party and use the --distdir flag
-# or modify the urls to "file:///<PATH TO TARBALL>/<TARBALL NAME>.tar.gz
+# or modify the urls to "file:///<PATH TO TARBALL>/<TARBALL NAME>.tar.gz
 
 #http_archive(
-#    name = "cudnn",
-#    urls = ["https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.0.1.13/10.2_20200626/cudnn-10.2-linux-x64-v8.0.1.13.tgz"],
-#    build_file = "@//third_party/cudnn/archive:BUILD",
-#    sha256 = "0c106ec84f199a0fbcf1199010166986da732f9b0907768c9ac5ea5b120772db",
-#    strip_prefix = "cuda"
+#    name = "cudnn",
+#    urls = ["https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.0.1.13/10.2_20200626/cudnn-10.2-linux-x64-v8.0.1.13.tgz"],
+#    build_file = "@//third_party/cudnn/archive:BUILD",
+#    sha256 = "0c106ec84f199a0fbcf1199010166986da732f9b0907768c9ac5ea5b120772db",
+#    strip_prefix = "cuda"
 #)
 
 #http_archive(
-#    name = "tensorrt",
-#    urls = ["https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/7.1/tars/TensorRT-7.1.3.4.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn8.0.tar.gz"],
-#    build_file = "@//third_party/tensorrt/archive:BUILD",
-#    sha256 = "9205bed204e2ae7aafd2e01cce0f21309e281e18d5bfd7172ef8541771539d41",
-#    strip_prefix = "TensorRT-7.1.3.4"
+#    name = "tensorrt",
+#    urls = ["https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/7.1/tars/TensorRT-7.1.3.4.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn8.0.tar.gz"],
+#    build_file = "@//third_party/tensorrt/archive:BUILD",
+#    sha256 = "9205bed204e2ae7aafd2e01cce0f21309e281e18d5bfd7172ef8541771539d41",
+#    strip_prefix = "TensorRT-7.1.3.4"
 #)
 
 NOTE: You may also need to configure the CUDA version to 10.2 by setting the path for the cuda new_local_repository
-
-
-
    -
  1. Configure the correct paths to directory roots containing local dependencies in the new_local_repository rules:

    -
    -

    NOTE: If you installed PyTorch using a pip package, the correct path is the path to the root of the python torch package. -In the case that you installed with sudo pip install this will be /usr/local/lib/python3.6/dist-packages/torch. -In the case you installed with pip install --user this will be $HOME/.local/lib/python3.6/site-packages/torch.

    -
    -
  2. -
-

In the case you are using NVIDIA compiled pip packages, set the path for both libtorch sources to the same path. This is because unlike + + + +

    +
  1. +

    + Configure the correct paths to directory roots containing local dependencies in the + + + new_local_repository + + + rules: +

    +
    +
    +

    + NOTE: If you installed PyTorch using a pip package, the correct path is the path to the root of the python torch package. +In the case that you installed with + + + sudo + + + pip + + + install + + + this will be + + + /usr/local/lib/python3.6/dist-packages/torch + + + . +In the case you installed with + + + pip + + + install + + + --user + + + this will be + + + $HOME/.local/lib/python3.6/site-packages/torch + + + . +

    +
    +
    +
  2. +
+

+ In the case you are using NVIDIA compiled pip packages, set the path for both libtorch sources to the same path. This is because unlike PyTorch on x86_64, NVIDIA aarch64 PyTorch uses the CXX11-ABI. If you compiled for source using the pre_cxx11_abi and only would like to -use that library, set the paths to the same path but when you compile make sure to add the flag --config=pre_cxx11_abi

-
new_local_repository(
-    name = "libtorch",
-    path = "/usr/local/lib/python3.6/dist-packages/torch",
-    build_file = "third_party/libtorch/BUILD"
+use that library, set the paths to the same path but when you compile make sure to add the flag
+        
+         
+          --config=pre_cxx11_abi
+         
+        
+       

+
+
+
new_local_repository(
+    name = "libtorch",
+    path = "/usr/local/lib/python3.6/dist-packages/torch",
+    build_file = "third_party/libtorch/BUILD"
 )
 
 new_local_repository(
-    name = "libtorch_pre_cxx11_abi",
-    path = "/usr/local/lib/python3.6/dist-packages/torch",
-    build_file = "third_party/libtorch/BUILD"
+    name = "libtorch_pre_cxx11_abi",
+    path = "/usr/local/lib/python3.6/dist-packages/torch",
+    build_file = "third_party/libtorch/BUILD"
 )
 
 new_local_repository(
-    name = "cudnn",
-    path = "/usr/",
-    build_file = "@//third_party/cudnn/local:BUILD"
+    name = "cudnn",
+    path = "/usr/",
+    build_file = "@//third_party/cudnn/local:BUILD"
 )
 
 new_local_repository(
-    name = "tensorrt",
-    path = "/usr/",
-    build_file = "@//third_party/tensorrt/local:BUILD"
+    name = "tensorrt",
+    path = "/usr/",
+    build_file = "@//third_party/tensorrt/local:BUILD"
 )
-
-
-
-
-

Compile C++ Library and Compiler CLI

-
-

NOTE: Due to shifting dependency locations between Jetpack 4.5 and 4.6 there is a now a flag to inform bazel of the Jetpack version

-
--platforms //toolchains:jetpack_4.x
-
-
-
-

Compile Torch-TensorRT library using bazel command:

-
bazel build //:libtorchtrt --platforms //toolchains:jetpack_4.6
-
-
-
-
-

Compile Python API

-
-

NOTE: Due to shifting dependencies locations between Jetpack 4.5 and Jetpack 4.6 there is now a flag for setup.py which sets the jetpack version (default: 4.6)

-
-

Compile the Python API using the following command from the //py directory:

-
python3 setup.py install --use-cxx11-abi
-
-
-

If you have a build of PyTorch that uses Pre-CXX11 ABI drop the --use-cxx11-abi flag

-

If you are building for Jetpack 4.5 add the --jetpack-version 4.5 flag

-
-
-

-
- - - - - - - - + - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-

Docs

-

Access comprehensive developer documentation for PyTorch

- View Docs + +

+ Compile Torch-TensorRT library using bazel command: +

+
+
+
bazel build //:libtorchtrt --platforms //toolchains:jetpack_4.6
+
- -
-

Tutorials

-

Get in-depth tutorials for beginners and advanced developers

- View Tutorials +
+

+ Compile Python API + + ¶ + +

+
+
+

+ NOTE: Due to shifting dependencies locations between Jetpack 4.5 and Jetpack 4.6 there is now a flag for + + + setup.py + + + which sets the jetpack version (default: 4.6) +

- -
-

Resources

-

Find development resources and get your questions answered

- View Resources +
+

+ Compile the Python API using the following command from the + + + //py + + + directory: +

+
+
+
python3 setup.py install --use-cxx11-abi
+
-
+
+

+ If you have a build of PyTorch that uses Pre-CXX11 ABI drop the + + + --use-cxx11-abi + + + flag +

+

+ If you are building for Jetpack 4.5 add the + + + --jetpack-version + + + 4.5 + + + flag +

+ +
+
- -
-
@@ -597,12 +597,12 @@

Citations @@ -611,9 +611,9 @@

Citations - - + + @@ -624,7 +624,7 @@

CitationsTwitter
  • YouTube
  • LinkedIn
  • - +

    - +
      @@ -751,7 +751,7 @@

      Resources

    • Ecosystem
    • - +
    • Mobile
    • @@ -813,7 +813,7 @@

      Resources

    • Resources
    • - +
      • diff --git a/docs/tutorials/runtime.html b/docs/tutorials/runtime.html index 35c95632fe..74784f326e 100644 --- a/docs/tutorials/runtime.html +++ b/docs/tutorials/runtime.html @@ -9,22 +9,22 @@ - - Deploying Torch-TensorRT Programs — Torch-TensorRT master documentation - - - - - + Deploying Torch-TensorRT Programs — Torch-TensorRT v1.3.0 documentation + + + + + + + + + + + - - - - - @@ -36,11 +36,11 @@ - + - - + + @@ -196,9 +196,9 @@ - - + +
      • YouTube
      • LinkedIn
      • -
      +
    - +
    - +
    - - - - - - - - - - - - - - - + - - -
    -
    -
    - - - - - - - - - - - - - - - - -
    - - - - -
    -
    - -
    - Shortcuts -
    +
    +
    +
    +
    + +
    - -
    -
    - - - -
    - -
    -
    - -
    -

    torchtrtc

    -

    torchtrtc is a CLI application for using the Torch-TensorRT compiler. It serves as an easy way to compile a +

    +
    +
    + + +

    + torchtrtc + + ¶ + +

    +

    + + + torchtrtc + + + is a CLI application for using the Torch-TensorRT compiler. It serves as an easy way to compile a TorchScript Module with Torch-TensorRT from the command-line to quickly check support or as part of a deployment pipeline. All basic features of the compiler are supported including post training quantization (though you must already have a calibration cache file to use the PTQ feature). The compiler can output two formats, either a TorchScript program with the TensorRT engine embedded or -the TensorRT engine itself as a PLAN file.

    -

    All that is required to run the program after compilation is for C++ linking against libtorchtrt.so -or in Python importing the torch_tensorrt package. All other aspects of using compiled modules are identical -to standard TorchScript. Load with torch.jit.load() and run like you would run any other module.

    -
    torchtrtc [input_file_path] [output_file_path]
    +the TensorRT engine itself as a PLAN file.
    +       

    +

    + All that is required to run the program after compilation is for C++ linking against + + + libtorchtrt.so + + + or in Python importing the torch_tensorrt package. All other aspects of using compiled modules are identical +to standard TorchScript. Load with + + + torch.jit.load() + + + and run like you would run any other module. +

    +
    +
    +
    torchtrtc [input_file_path] [output_file_path]
       [input_specs...] {OPTIONS}
     
       torchtrtc is a compiler for TorchScript, it will compile and optimize
    @@ -436,12 +593,10 @@
                                           used to select kernels
         --workspace-size=[workspace_size] Maximum size of workspace given to
                                           TensorRT
    -    --atol=[atol]                     Absolute tolerance threshold for acceptable
    -                                      numerical deviation from standard torchscript
    -                                      output (default 1e-8)
    -    --rtol=[rtol]                     Relative tolerance threshold for acceptable
    -                                      numerical deviation from standard torchscript
    -                                      output  (default 1e-5)
    +    -t[threshold],
    +    --threshold=[threshold]           Maximum acceptable numerical deviation
    +                                      from standard torchscript output
    +                                      (default 2e-5)
         --no-threshold-check              Skip checking threshold compliance
         --truncate-long-double,
         --truncate, --truncate-64bit      Truncate weights that are provided in
    @@ -457,310 +612,89 @@
         input_specs...                    Specs for inputs to engine, can either
                                           be a single size or a range defined by
                                           Min, Optimal, Max sizes, e.g.
    -                                      "(N,..,C,H,W)"
    -                                      "[(MIN_N,..,MIN_C,MIN_H,MIN_W);(OPT_N,..,OPT_C,OPT_H,OPT_W);(MAX_N,..,MAX_C,MAX_H,MAX_W)]".
    +                                      "(N,..,C,H,W)"
    +                                      "[(MIN_N,..,MIN_C,MIN_H,MIN_W);(OPT_N,..,OPT_C,OPT_H,OPT_W);(MAX_N,..,MAX_C,MAX_H,MAX_W)]".
                                           Data Type and format can be specified by
    -                                      adding an "@" followed by dtype and "%"
    +                                      adding an "@" followed by dtype and "%"
                                           followed by format to the end of the
    -                                      shape spec. e.g. "(3, 3, 32,
    -                                      32)@f16%NHWC"
    -    "--" can be used to terminate flag options and force all following
    +                                      shape spec. e.g. "(3, 3, 32,
    +                                      32)@f16%NHWC"
    +    "--" can be used to terminate flag options and force all following
         arguments to be treated as positional options
    -
    -
    -

    e.g.

    -
    torchtrtc tests/modules/ssd_traced.jit.pt ssd_trt.ts "[(1,3,300,300); (1,3,512,512); (1, 3, 1024, 1024)]@f16%contiguous" -p f16
    -
    -
    -
    - - - - -
    - - -
    + - -
    -
    -
    - - -
    -
    +
    +

    + e.g. +

    +
    +
    +
    torchtrtc tests/modules/ssd_traced.jit.pt ssd_trt.ts "[(1,3,300,300); (1,3,512,512); (1, 3, 1024, 1024)]@f16%contiguous" -p f16
    +
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    -
    -

    Docs

    -

    Access comprehensive developer documentation for PyTorch

    - View Docs -
    - -
    -

    Tutorials

    -

    Get in-depth tutorials for beginners and advanced developers

    - View Tutorials -
    - -
    -

    Resources

    -

    Find development resources and get your questions answered

    - View Resources -
    -
    +
    + +
    + - -