Skip to content

Commit afa97b9

Browse files
committed
chore: Updates to documentation
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent 3892498 commit afa97b9

File tree

12 files changed

+760
-148
lines changed

12 files changed

+760
-148
lines changed

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,25 @@ More Information / System Architecture:
1212

1313

1414

15-
## Building a docker container for Torch-TensorRT Preview
15+
## Building a docker container for Torch-TensorRT
1616

17-
We provide a `Dockerfile` in `docker/` directory. We build `Torch-TensorRT` on top of a `Pytorch NGC container` which provide basic dependencies (like CUDA, CUDNN, CUBLAS, TensorRT, Pytorch and others) The dependency libraries in the container can be found in the <a href="https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/index.html">release notes</a>.
17+
We provide a `Dockerfile` in `docker/` directory. It expects a PyTorch NGC container as a base but can easily be modified to build on top of any container that provides, PyTorch, CUDA, cuDNN and TensorRT. The dependency libraries in the container can be found in the <a href="https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/index.html">release notes</a>.
1818

1919
Please follow this instruction to build a Docker container.
2020

2121
```bash
22-
docker build -f docker/Dockerfile -t torch_tensorrt_preview:latest .
22+
docker build --build-arg BASE=<CONTAINER VERSION e.g. 21.11> -f docker/Dockerfile -t torch_tensorrt:latest .
23+
```
24+
25+
In the case of building on top of a custom base container, you first must determine the
26+
version of the PyTorch C++ ABI. If your source of PyTorch is pytorch.org, likely this is the pre-cxx11-abi in which case you must modify `//docker/dist-build.sh` to not build the
27+
C++11 ABI version of Torch-TensorRT.
28+
29+
You can then build the container using:
30+
31+
32+
```bash
33+
docker build --build-arg BASE_IMG=<IMAGE> -f docker/Dockerfile -t torch_tensorrt:latest .
2334
```
2435

2536
If you would like to build outside a docker container, please follow the section [Compiling Torch-TensorRT](#compiling-torch-tensorrt)
@@ -86,18 +97,19 @@ torch.jit.save(trt_ts_module, "trt_torchscript_module.ts") # save the TRT embedd
8697
| Linux aarch64 / DLA | **Native Compilation Supported on JetPack-4.4+** |
8798
| Windows / GPU | **Unofficial Support** |
8899
| Linux ppc64le / GPU | - |
100+
| NGC Containers | **Including in PyTorch NGC Containers 21.11+** |
89101

90-
Torch-TensorRT will be included in NVIDIA NGC containers (https://ngc.nvidia.com/catalog/containers/nvidia:pytorch) starting in 21.11.
102+
> Torch-TensorRT will be included in NVIDIA NGC containers (https://ngc.nvidia.com/catalog/containers/nvidia:pytorch) starting in 21.11.
91103
92104
> Note: Refer NVIDIA NGC container(https://ngc.nvidia.com/catalog/containers/nvidia:l4t-pytorch) for PyTorch libraries on JetPack.
93105
94106
### Dependencies
95107

96108
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.
97109

98-
- Bazel 4.0.0
110+
- Bazel 4.2.1
99111
- Libtorch 1.10.0 (built with CUDA 11.3)
100-
- CUDA 11.1 (10.2 on Jetson)
112+
- CUDA 11.3 (10.2 on Jetson)
101113
- cuDNN 8.2
102114
- TensorRT 8.0.3.4 (TensorRT 8.0.1.6 on Jetson)
103115

@@ -147,7 +159,7 @@ bazel build //:libtorchtrt --compilation_mode opt --distdir third_party/dist_dir
147159

148160
#### 2. Building using locally installed cuDNN & TensorRT
149161

150-
> If you find bugs and you compiled using this method please disclose it in the issue
162+
> If you find bugs and you compiled using this method please disclose you used this method in the issue
151163
> (an `ldd` dump would be nice too)
152164
153165
1. Install TensorRT, CUDA and cuDNN on the system before starting to compile.

cpp/include/torch_tensorrt/torch_tensorrt.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ class TORCHTRT_API DataType {
141141
Value value;
142142
};
143143

144-
/*
145-
* Setting data structure for Target device
144+
/**
145+
* @brief Setting data structure for Target device
146146
*/
147147
struct Device {
148148
/**
@@ -262,6 +262,10 @@ enum class EngineCapability : int8_t {
262262
kDLA_STANDALONE,
263263
};
264264

265+
266+
/**
267+
* @brief TensorFormat is an enum class which defines the memeory layout used to store Tensor Data
268+
* */
265269
class TORCHTRT_API TensorFormat {
266270
public:
267271
/**
@@ -382,8 +386,6 @@ struct TORCHTRT_API Input {
382386
* / traditional TRT convection (FP32 for FP32 only, FP16 for FP32 and FP16, FP32 for Int8)
383387
*
384388
* @param shape Input tensor shape
385-
* @param dtype Expected data type for the input (Defaults to the type of the weights in the first tensor
386-
* calculation if detectable else Float32)
387389
* @param format Expected tensor format for the input (Defaults to contiguous)
388390
*/
389391
Input(std::vector<int64_t> shape, TensorFormat format = TensorFormat::kContiguous);

docsrc/index.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,54 @@ Getting Started
4343
tutorials/use_from_pytorch
4444
tutorials/runtime
4545
tutorials/using_dla
46-
_notebooks/lenet
4746

4847
.. toctree::
4948
:caption: Notebooks
5049
:maxdepth: 1
5150
:hidden:
5251

5352
_notebooks/lenet-getting-started
53+
_notebooks/Resnet50-example
5454
_notebooks/ssd-object-detection-demo
5555
_notebooks/vgg-qat
5656

5757

5858
Python API Documenation
5959
------------------------
6060
* :ref:`torch_tensorrt_py`
61+
* :ref:`torch_tensorrt_logging_py`
62+
* :ref:`torch_tensorrt_ptq_py`
63+
* :ref:`torch_tensorrt_ts_py`
64+
6165

6266
.. toctree::
6367
:caption: Python API Documenation
6468
:maxdepth: 0
6569
:hidden:
6670

6771
py_api/torch_tensorrt
68-
py_api/ts
6972
py_api/logging
73+
py_api/ptq
74+
py_api/ts
7075

7176
C++ API Documenation
7277
----------------------
7378
* :ref:`namespace_torch_tensorrt`
79+
* :ref:`namespace_torch_tensorrt__logging`
80+
* :ref:`namespace_torch_tensorrt__ptq`
81+
* :ref:`namespace_torch_tensorrt__torchscript`
82+
7483

7584
.. toctree::
7685
:caption: C++ API Documenation
7786
:maxdepth: 1
7887
:hidden:
7988

80-
_cpp_api/torch_tensorrt_cpp
89+
_cpp_api/torch_tensort_cpp
90+
_cpp_api/namespace_torch_tensorrt
91+
_cpp_api/namespace_torch_tensorrt__logging
92+
_cpp_api/namespace_torch_tensorrt__torchscript
93+
_cpp_api/namespace_torch_tensorrt__ptq
8194

8295
Contributor Documentation
8396
--------------------------------

docsrc/py_api/logging.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _torch_tensorrt_logging_py:
2+
13
torch_tensorrt.logging
24
----------------------
35

docsrc/py_api/ptq.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.. _torch_tensorrt_ptq_py:
2+
3+
torch_tensorrt.ptq
4+
----------------------
5+
6+
.. currentmodule:: torch_tensorrt.ptq
7+
8+
.. automodule:: torch_tensorrt.ptq
9+
:members:
10+
:undoc-members:
11+
:show-inheritance:
12+
13+
Classes
14+
---------
15+
16+
.. autoclass:: DataLoaderCalibrator
17+
:members:
18+
:special-members: __init__
19+
20+
.. autoclass:: CacheCalibrator
21+
:members:
22+
:special-members: __init__
23+
24+
Enums
25+
-------
26+
27+
.. autoclass:: CalibrationAlgo

docsrc/py_api/torch_tensorrt.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
.. _torch_tensorrt_py:
22

3+
torch_tensorrt
4+
===============
5+
36
.. automodule torch_tensorrt
47
:undoc-members:
58
6-
torch_tensorrt
7-
===============
9+
810
911
.. automodule:: torch_tensorrt
1012
:members:
@@ -53,4 +55,6 @@ Submodules
5355
:maxdepth: 1
5456

5557
logging
58+
ptq
5659
ts
60+

docsrc/py_api/ts.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _torch_tensorrt_ts_py:
2+
13
torch_tensorrt.ts
24
===================
35

docsrc/tutorials/installation.rst

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ You can install the python package using
2525

2626
.. code-block:: sh
2727
28-
pip3 install torch_tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases
28+
pip3 install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases
2929
3030
.. _bin-dist:
3131

@@ -46,7 +46,7 @@ Dependencies for Compilation
4646

4747
Torch-TensorRT is built with Bazel, so begin by installing it.
4848

49-
* The easiest way is to install bazelisk using the method of you choosing https://github.com/bazelbuild/bazelisk
49+
* The easiest way is to install bazelisk using the method of your choosing https://github.com/bazelbuild/bazelisk
5050
* Otherwise you can use the following instructions to install binaries https://docs.bazel.build/versions/master/install.html
5151
* Finally if you need to compile from source (e.g. aarch64 until bazel distributes binaries for the architecture) you can use these instructions
5252

@@ -67,9 +67,40 @@ the CUDA driver installed and the container must have CUDA)
6767
The correct LibTorch version will be pulled down for you by bazel.
6868

6969
NOTE: For best compatability with official PyTorch, use torch==1.10.0+cuda113, TensorRT 8.0 and cuDNN 8.2 for CUDA 11.3 however Torch-TensorRT itself supports
70-
TensorRT and cuDNN for CUDA versions other than 11.1 for usecases such as using NVIDIA compiled distributions of PyTorch that use other versions of CUDA
70+
TensorRT and cuDNN for other CUDA versions for usecases such as using NVIDIA compiled distributions of PyTorch that use other versions of CUDA
7171
e.g. aarch64 or custom compiled version of PyTorch.
7272

73+
.. _abis:
74+
75+
Choosing the Right ABI
76+
^^^^^^^^^^^^^^^^^^^^^^^^
77+
78+
Likely the most complicated thing about compiling Torch-TensorRT is selecting the correct ABI. There are two options
79+
which are incompatible with each other, pre-cxx11-abi and the cxx11-abi. The complexity comes from the fact that while
80+
the most popular distribution of PyTorch (wheels downloaded from pytorch.org/pypi directly) use the pre-cxx11-abi, most
81+
other distributions you might encounter (e.g. ones from NVIDIA - NGC containers, and builds for Jetson as well as certain
82+
libtorch builds and likely if you build PyTorch from source) use the cxx11-abi. It is important you compile Torch-TensorRT
83+
using the correct ABI to function properly. Below is a table with general pairings of PyTorch distribution sources and the
84+
recommended commands:
85+
86+
+-------------------------------------------------------------+----------------------------------------------------------+--------------------------------------------------------------------+
87+
| PyTorch Source | Recommended C++ Compilation Command | Recommended Python Compilation Command |
88+
+=============================================================+==========================================================+====================================================================+
89+
| PyTorch whl file from PyTorch.org | bazel build //:libtorchtrt -c opt --config pre_cxx11_abi | python3 setup.py bdist_wheel |
90+
+-------------------------------------------------------------+----------------------------------------------------------+--------------------------------------------------------------------+
91+
| libtorch-shared-with-deps-*.zip from PyTorch.org | bazel build //:libtorchtrt -c opt --config pre_cxx11_abi | python3 setup.py bdist_wheel |
92+
+-------------------------------------------------------------+----------------------------------------------------------+--------------------------------------------------------------------+
93+
| libtorch-cxx11-abi-shared-with-deps-*.zip from PyTorch.org | bazel build //:libtorchtrt -c opt | python3 setup.py bdist_wheel --use-cxx11-abi |
94+
+-------------------------------------------------------------+----------------------------------------------------------+--------------------------------------------------------------------+
95+
| PyTorch preinstalled in an NGC container | bazel build //:libtorchtrt -c opt | python3 setup.py bdist_wheel --use-cxx11-abi |
96+
+-------------------------------------------------------------+----------------------------------------------------------+--------------------------------------------------------------------+
97+
| PyTorch from the NVIDIA Forums for Jetson | bazel build //:libtorchtrt -c opt | python3 setup.py bdist_wheel --jetpack-version 4.6 --use-cxx11-abi |
98+
+-------------------------------------------------------------+----------------------------------------------------------+--------------------------------------------------------------------+
99+
| PyTorch built from Source | bazel build //:libtorchtrt -c opt | python3 setup.py bdist_wheel --use-cxx11-abi |
100+
+-------------------------------------------------------------+----------------------------------------------------------+--------------------------------------------------------------------+
101+
102+
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
103+
73104
You then have two compilation options:
74105

75106
.. _build-from-archive:

docsrc/tutorials/use_from_pytorch.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _use_from_pytorch:
22

33
Using Torch-TensorRT Directly From PyTorch
4-
====================================
4+
============================================
55

66
You will now be able to directly access TensorRT from PyTorch APIs. The process to use this feature
77
is very similar to the compilation workflow described in :ref:`getting_started_with_python_api`
@@ -33,7 +33,7 @@ at the documentation for the Torch-TensorRT ``TensorRTCompileSpec`` API.
3333
3434
spec = {
3535
"forward":
36-
torch_tensorrt.TensorRTCompileSpec({
36+
torch_tensorrt.ts.TensorRTCompileSpec({
3737
"inputs": [torch_tensorrt.Input([1, 3, 300, 300])],
3838
"enabled_precisions": {torch.float, torch.half},
3939
"refit": False,

0 commit comments

Comments
 (0)