Skip to content

Commit 76d879c

Browse files
peri044gs-olive
andauthored
feat: Upgrade Pytorch and TensorRT versions (#1759)
Signed-off-by: Dheeraj Peri <[email protected]> Co-authored-by: gs-olive <[email protected]>
1 parent a9d8bd9 commit 76d879c

32 files changed

+1682
-1590
lines changed

.circleci/config.yml

Lines changed: 109 additions & 58 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ In the case of building on top of a custom base container, you first must determ
3131
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
3232
C++11 ABI version of Torch-TensorRT.
3333

34-
You can then build the container using:
35-
36-
37-
```bash
38-
docker build --build-arg BASE_IMG=<IMAGE> -f docker/Dockerfile -t torch_tensorrt:latest .
39-
```
34+
You can then build the container using the build command in the [docker README](docker/README.md#instructions)
4035

4136
If you would like to build outside a docker container, please follow the section [Compiling Torch-TensorRT](#compiling-torch-tensorrt)
4237

@@ -121,17 +116,17 @@ torch.jit.save(trt_ts_module, "trt_torchscript_module.ts") # save the TRT embedd
121116
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.
122117

123118
- Bazel 5.2.0
124-
- Libtorch 2.0.0.dev20230103 (built with CUDA 11.7)
125-
- CUDA 11.7
126-
- cuDNN 8.5.0
127-
- TensorRT 8.5.1.7
119+
- Libtorch 2.0.1 (built with CUDA 11.8)
120+
- CUDA 11.8
121+
- cuDNN 8.8.0
122+
- TensorRT 8.6.0
128123

129124
## Prebuilt Binaries and Wheel files
130125

131126
Releases: https://github.com/pytorch/TensorRT/releases
132127

133128
```
134-
pip install torch-tensorrt==1.2.0 --find-links https://github.com/pytorch/TensorRT/releases/expanded_assets/v1.2.0
129+
pip install torch-tensorrt
135130
```
136131

137132
## Compiling Torch-TensorRT
@@ -252,7 +247,7 @@ A tarball with the include files and library can then be found in bazel-bin
252247
### Running Torch-TensorRT on a JIT Graph
253248

254249
> Make sure to add LibTorch to your LD_LIBRARY_PATH <br>
255-
> `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/bazel-Torch-TensorRT/external/libtorch/lib`
250+
> `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/bazel-TensorRT/external/libtorch/lib`
256251
257252
``` shell
258253
bazel run //cpp/bin/torchtrtc -- $(realpath <PATH TO GRAPH>) out.ts <input-size>

WORKSPACE

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,27 @@ local_repository(
4141
new_local_repository(
4242
name = "cuda",
4343
build_file = "@//third_party/cuda:BUILD",
44-
path = "/usr/local/cuda-11.7/",
44+
path = "/usr/local/cuda-11.8/",
4545
)
4646

47-
new_local_repository(
48-
name = "cublas",
49-
build_file = "@//third_party/cublas:BUILD",
50-
path = "/usr",
51-
)
5247
#############################################################################################################
5348
# Tarballs and fetched dependencies (default - use in cases when building from precompiled bin and tarballs)
5449
#############################################################################################################
5550

5651
http_archive(
5752
name = "libtorch",
5853
build_file = "@//third_party/libtorch:BUILD",
59-
sha256 = "8b3b48615169c83c1b643c0efade078ea080b1da598e15fcf01bc59421f3095e",
54+
sha256 = "c5174f18c0866421a5738d389aaea0c02f32a1a5be5f0747dc8dd0d96034c9b0",
6055
strip_prefix = "libtorch",
61-
urls = ["https://download.pytorch.org/libtorch/nightly/cu117/libtorch-cxx11-abi-shared-with-deps-2.0.0.dev20230219%2Bcu117.zip"],
56+
urls = ["https://download.pytorch.org/libtorch/test/cu118/libtorch-cxx11-abi-shared-with-deps-latest.zip"],
6257
)
6358

6459
http_archive(
6560
name = "libtorch_pre_cxx11_abi",
6661
build_file = "@//third_party/libtorch:BUILD",
67-
sha256 = "aa7fd06079d260ff83c344d043fb84fbd9cf831cf375ed8b5a1b62416817af31",
62+
sha256 = "cc19b398cf435e0e34f347ef90fc11c2a42703998330a9c4a9fb0d2291737df7",
6863
strip_prefix = "libtorch",
69-
urls = ["https://download.pytorch.org/libtorch/nightly/cu117/libtorch-shared-with-deps-2.0.0.dev20230219%2Bcu117.zip"],
64+
urls = ["https://download.pytorch.org/libtorch/test/cu118/libtorch-shared-with-deps-latest.zip"],
7065
)
7166

7267
# Download these tarballs manually from the NVIDIA website
@@ -76,20 +71,20 @@ http_archive(
7671
http_archive(
7772
name = "cudnn",
7873
build_file = "@//third_party/cudnn/archive:BUILD",
79-
sha256 = "5454a6fd94f008728caae9adad993c4e85ef36302e26bce43bea7d458a5e7b6d",
80-
strip_prefix = "cudnn-linux-x86_64-8.5.0.96_cuda11-archive",
74+
sha256 = "36fff137153ef73e6ee10bfb07f4381240a86fb9fb78ce372414b528cbab2293",
75+
strip_prefix = "cudnn-linux-x86_64-8.8.0.121_cuda11-archive",
8176
urls = [
82-
"https://developer.nvidia.com/compute/cudnn/secure/8.5.0/local_installers/11.7/cudnn-linux-x86_64-8.5.0.96_cuda11-archive.tar.xz",
77+
"https://developer.download.nvidia.com/compute/cudnn/secure/8.8.0/local_installers/11.8/cudnn-linux-x86_64-8.8.0.121_cuda11-archive.tar.xz",
8378
],
8479
)
8580

8681
http_archive(
8782
name = "tensorrt",
8883
build_file = "@//third_party/tensorrt/archive:BUILD",
89-
sha256 = "39cc7f077057d1363794e8ff51c4cf21a5dbeccf1116b0020ba0dae0f3063076",
90-
strip_prefix = "TensorRT-8.5.1.7",
84+
sha256 = "c1732a1093c57ab79fa0b687f061be369e449c9c17792b660f3663ecd8fa7b63",
85+
strip_prefix = "TensorRT-8.6.0.12",
9186
urls = [
92-
"https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/8.5.1/tars/TensorRT-8.5.1.7.Linux.x86_64-gnu.cuda-11.8.cudnn8.6.tar.gz",
87+
"https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/secure/8.6.0/tars/TensorRT-8.6.0.12.Linux.x86_64-gnu.cuda-11.8.tar.gz",
9388
],
9489
)
9590

core/runtime/TRTEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ TRTEngine::TRTEngine(
150150
}
151151

152152
TRTEngine::~TRTEngine() {
153-
rt.reset();
154153
trt_engine_profiler.reset();
155154
exec_ctx.reset();
156155
cuda_engine.reset();
156+
rt.reset();
157157
}
158158

159159
void TRTEngine::disable_profiling() {

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Base image starts with CUDA
2-
ARG BASE_IMG=nvidia/cuda:11.7.1-devel-ubuntu22.04
2+
ARG BASE_IMG=nvidia/cuda:11.8.0-devel-ubuntu22.04
33
FROM ${BASE_IMG} as base
44

55
ARG TENSORRT_VERSION

docker/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
* The `Dockerfile` currently uses <a href="https://github.com/bazelbuild/bazelisk">Bazelisk</a> to select the Bazel version, and uses the exact library versions of Torch and CUDA listed in <a href="https://github.com/pytorch/TensorRT#dependencies">dependencies</a>.
66
* The desired versions of CUDNN and TensorRT must be specified as build-args, with major, minor, and patch versions as in: `--build-arg TENSORRT_VERSION=a.b.c --build-arg CUDNN_VERSION=x.y.z`
7-
* [**Optional**] The desired base image be changed by explicitly setting a base image, as in `--build-arg BASE_IMG=nvidia/cuda:11.7.1-devel-ubuntu22.04`, though this is optional
7+
* [**Optional**] The desired base image be changed by explicitly setting a base image, as in `--build-arg BASE_IMG=nvidia/cuda:11.8.0-devel-ubuntu22.04`, though this is optional
88
* [**Optional**] Additionally, the desired Python version can be changed by explicitly setting a version, as in `--build-arg PYTHON_VERSION=3.10`, though this is optional as well.
99

1010
* This `Dockerfile` installs `pre-cxx11-abi` versions of Pytorch and builds Torch-TRT using `pre-cxx11-abi` libtorch as well.
@@ -17,14 +17,14 @@ Note: By default the container uses the `pre-cxx11-abi` version of Torch + Torch
1717

1818
### Instructions
1919

20-
- The example below uses CUDNN 8.5.0 and TensorRT 8.5.1
20+
- The example below uses CUDNN 8.8.0 and TensorRT 8.6.0
2121
- See <a href="https://github.com/pytorch/TensorRT#dependencies">dependencies</a> for a list of current default dependencies.
2222

2323
> From root of Torch-TensorRT repo
2424
2525
Build:
2626
```
27-
DOCKER_BUILDKIT=1 docker build --build-arg TENSORRT_VERSION=8.5.1 --build-arg CUDNN_VERSION=8.5.0 -f docker/Dockerfile -t torch_tensorrt:latest .
27+
DOCKER_BUILDKIT=1 docker build --build-arg TENSORRT_VERSION=8.6.0 --build-arg CUDNN_VERSION=8.8.0 -f docker/Dockerfile -t torch_tensorrt:latest .
2828
```
2929

3030
Run:

py/ci/build_whl.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Example usage: docker run -it -v$(pwd)/..:/workspace/TRTorch build_trtorch_wheel /bin/bash /workspace/TRTorch/py/build_whl.sh
44

55
export CXX=g++
6-
export CUDA_HOME=/usr/local/cuda-11.7
6+
export CUDA_HOME=/usr/local/cuda-11.8
77
export PROJECT_DIR=/workspace/project
88

99
cp -r $CUDA_HOME /usr/local/cuda
@@ -108,4 +108,4 @@ libtorchtrt_pre_cxx11_abi() {
108108
CUDNN_VERSION=$(cd ${PROJECT_DIR}/py && ${PY_DIR}/bin/python3 -c "from versions import __cudnn_version__;print(__cudnn_version__)")
109109
TORCH_VERSION=$(${PY_DIR}/bin/python -c "from torch import __version__;print(__version__.split('+')[0])")
110110
cp ${PROJECT_DIR}/bazel-bin/libtorchtrt.tar.gz ${PROJECT_DIR}/py/wheelhouse/libtorchtrt-${TORCHTRT_VERSION}-pre-cxx11-abi-cudnn${CUDNN_VERSION}-tensorrt${TRT_VERSION}-cuda${CUDA_VERSION}-libtorch${TORCH_VERSION}-x86_64-linux.tar.gz
111-
}
111+
}

py/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
numpy
22
packaging
33
pybind11==2.6.2
4-
--extra-index-url https://download.pytorch.org/whl/nightly/cu117
5-
torch==2.1.0.dev20230314+cu117
6-
torchvision==0.15.0.dev20230219+cu117
4+
--extra-index-url https://download.pytorch.org/whl/test/cu118
5+
torch==2.0.1
6+
torchvision==0.15.2
77
--extra-index-url https://pypi.ngc.nvidia.com
8-
tensorrt==8.5.1.7
8+
tensorrt==8.6.0

py/setup.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
FX_ONLY = False
3333

34+
LEGACY = False
35+
3436
RELEASE = False
3537

3638
CI_RELEASE = False
@@ -48,6 +50,10 @@ def get_git_revision_short_hash() -> str:
4850
FX_ONLY = True
4951
sys.argv.remove("--fx-only")
5052

53+
if "--legacy" in sys.argv:
54+
LEGACY = True
55+
sys.argv.remove("--legacy")
56+
5157
if "--release" not in sys.argv:
5258
__version__ = __version__ + "+" + get_git_revision_short_hash()
5359
else:
@@ -380,7 +386,7 @@ def run(self):
380386
long_description=long_description,
381387
ext_modules=ext_modules,
382388
install_requires=[
383-
"torch>=1.13.1",
389+
"torch >=2.0.1,<2.1" if not LEGACY else "torch >=1.13.0,<2.0",
384390
],
385391
setup_requires=[],
386392
cmdclass={
@@ -409,7 +415,7 @@ def run(self):
409415
"Topic :: Software Development",
410416
"Topic :: Software Development :: Libraries",
411417
],
412-
python_requires=">=3.7",
418+
python_requires=">=3.8",
413419
include_package_data=True,
414420
package_data={
415421
"torch_tensorrt": [

py/torch_tensorrt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _find_lib(name, paths):
5858

5959
elif sys.platform.startswith("linux"):
6060
LINUX_PATHS = [
61-
"/usr/local/cuda/lib64",
61+
"/usr/local/cuda-11.8/lib64",
6262
]
6363

6464
if "LD_LIBRARY_PATH" in os.environ:

py/torch_tensorrt/fx/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ FX2TRT is merged as FX module in Torch-TensorRT
88
```
99
$ conda create --name python_env python=3.8
1010
$ conda activate python_env
11-
# Recommend to install PyTorch 1.12 and later
12-
$ conda install pytorch torchvision torchtext cudatoolkit=11.3 -c pytorch-nightly
11+
# Recommend to install PyTorch 2.0 and later
12+
$ conda install pytorch torchvision torchtext cudatoolkit=11.8 -c pytorch-nightly
1313
# Install TensorRT python package
1414
$ pip3 install nvidia-pyindex
15-
$ pip3 install tensorrt==8.5.1.7
15+
$ pip3 install tensorrt==8.6.0.12
1616
$ git clone https://github.com/pytorch/TensorRT.git
1717
$ cd TensorRT/py && python setup.py install --fx-only && cd ..
18-
$ pyton -c "import torch_tensorrt.fx"
18+
$ python -c "import torch_tensorrt.fx"
1919
# Test an example by
2020
$ python py/torch_tensorrt/fx/example/lower_example.py
2121
```

py/torch_tensorrt/fx/passes/lower_basic_pass_aten.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ def replace_aten_op_with_indices(module: torch.fx.GraphModule) -> torch.fx.Graph
165165
torch.ops.aten.max_pool3d_with_indices.default,
166166
torch.ops.aten.native_batch_norm.default,
167167
torch.ops.aten._native_batch_norm_legit.default,
168-
torch.ops.aten._native_batch_norm_legit_no_training.default,
169168
):
170169
modified = True
171170
if len(n.users) != 1:
@@ -186,16 +185,6 @@ def replace_aten_op_with_indices(module: torch.fx.GraphModule) -> torch.fx.Graph
186185
new_args = list(n.args)
187186
new_args.append(False)
188187
new_args = tuple(new_args)
189-
elif (
190-
n.target == torch.ops.aten._native_batch_norm_legit_no_training.default
191-
):
192-
new_op = torch.ops.aten.batch_norm
193-
new_args = list(n.args)
194-
new_args.append(False)
195-
# _native_batch_norm_legit_no_training doesn't take in a training arg (assumed to be false)
196-
# but batchnorm takes in a training arg at position 5.
197-
new_args.insert(5, False)
198-
new_args = tuple(new_args)
199188

200189
getitem_node = next(iter(n.users))
201190
with module.graph.inserting_after(getitem_node):

py/torch_tensorrt/fx/test/passes/test_fuse_permute_linear_trt.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ def forward(self, x):
5454
apply_passes=[fuse_permute_linear],
5555
)
5656

57-
# TODO: The following test has been disabled due to a bug in TRT 8.5.1.7
58-
# with self.linear2. Issue : https://github.com/pytorch/TensorRT/issues/1444
59-
@unittest.skip(
60-
reason="test_multi_fuse_permute_linear has been disabled due to a bug in TRT 8.5.1.7 https://github.com/pytorch/TensorRT/issues/1444"
61-
)
6257
def test_multi_fuse_permute_linear(self):
6358
"""
6459
Fusion when permute output is shared by multiple linears

py/versions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__version__ = "1.4.0.rc0"
2-
__cuda_version__ = "11.7"
3-
__cudnn_version__ = "8.5"
4-
__tensorrt_version__ = "8.5"
2+
__cuda_version__ = "11.8"
3+
__cudnn_version__ = "8.8"
4+
__tensorrt_version__ = "8.6"

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ requires = [
99
"cffi",
1010
"typing_extensions",
1111
"future",
12-
"nvidia-pyindex",
13-
"nvidia-tensorrt==8.4.3.1"
12+
"tensorrt >=8.6,<8.7"
1413
]
1514

1615
# Use legacy backend to import local packages in setup.py
@@ -20,7 +19,7 @@ requires = [
2019
[tool.black]
2120
# Uncomment if pyproject.toml worked fine to ensure consistency with flake8
2221
# line-length = 120
23-
target-versions = ["py37", "py38", "py39", "py310"]
22+
target-versions = ["py38", "py39", "py310"]
2423
force-exclude = """
2524
elu_converter/setup.py
2625
"""

0 commit comments

Comments
 (0)