Skip to content

Commit ac3ab77

Browse files
gs-oliveperi044
andauthored
fix: Upgrade main to TRT 8.6, CUDA 11.8, CuDNN 8.8, Torch Dev (#1852)
Signed-off-by: Dheeraj Peri <[email protected]> Co-authored-by: Dheeraj Peri <[email protected]>
1 parent 39585b1 commit ac3ab77

33 files changed

+1697
-1579
lines changed

.circleci/config.yml

+120-59
Large diffs are not rendered by default.

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ torch.jit.save(trt_ts_module, "trt_torchscript_module.ts") # save the TRT embedd
116116
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.
117117

118118
- Bazel 5.2.0
119-
- Libtorch 2.1.0.dev20230314 (built with CUDA 11.7)
120-
- CUDA 11.7
121-
- cuDNN 8.5.0
122-
- TensorRT 8.5.1.7
119+
- Libtorch 2.1.0.dev20230419 (built with CUDA 11.8)
120+
- CUDA 11.8
121+
- cuDNN 8.8.0
122+
- TensorRT 8.6.0
123123

124124
## Prebuilt Binaries and Wheel files
125125

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

249249
> Make sure to add LibTorch to your LD_LIBRARY_PATH <br>
250-
> `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`
251251
252252
``` shell
253253
bazel run //cpp/bin/torchtrtc -- $(realpath <PATH TO GRAPH>) out.ts <input-size>

WORKSPACE

+11-16
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 = "7c4b8754830fef23ec19c5eaf414794cee9597b435df055f5c1d0471d3e81568",
54+
sha256 = "1a526a9cd19c1015674d26921dbb94bcd2d632a6f9c431a21c43f4e24768d834",
6055
strip_prefix = "libtorch",
61-
urls = ["https://download.pytorch.org/libtorch/nightly/cu117/libtorch-cxx11-abi-shared-with-deps-2.1.0.dev20230314%2Bcu117.zip"],
56+
urls = ["https://download.pytorch.org/libtorch/nightly/cu118/libtorch-cxx11-abi-shared-with-deps-2.1.0.dev20230419%2Bcu118.zip"],
6257
)
6358

6459
http_archive(
6560
name = "libtorch_pre_cxx11_abi",
6661
build_file = "@//third_party/libtorch:BUILD",
67-
sha256 = "f1e64a75dd12d0ba4c8c1f61947299e0a9c50684dff64f0cfbf355aa7a13e8cf",
62+
sha256 = "60c5912a5085a6a7073b3804b10d41d6cc054693bbeb7a45e0247050c2837bac",
6863
strip_prefix = "libtorch",
69-
urls = ["https://download.pytorch.org/libtorch/nightly/cu117/libtorch-shared-with-deps-2.1.0.dev20230314%2Bcu117.zip"],
64+
urls = ["https://download.pytorch.org/libtorch/nightly/cu118/libtorch-shared-with-deps-2.1.0.dev20230419%2Bcu118.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

+1-1
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() {

cpp/include/torch_tensorrt/macros.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define STR(x) XSTR(x)
2525

2626
#define TORCH_TENSORRT_MAJOR_VERSION 1
27-
#define TORCH_TENSORRT_MINOR_VERSION 3
27+
#define TORCH_TENSORRT_MINOR_VERSION 5
2828
#define TORCH_TENSORRT_PATCH_VERSION 0
2929
#define TORCH_TENSORRT_VERSION \
3030
STR(TORCH_TENSORRT_MAJOR_VERSION) \

docker/Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
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
4-
ENV BASE_IMG=nvidia/cuda:11.7.1-devel-ubuntu22.04
4+
ENV BASE_IMG=nvidia/cuda:11.8.0-devel-ubuntu22.04
55

66
ARG TENSORRT_VERSION
77
ENV TENSORRT_VERSION=${TENSORRT_VERSION}
8-
RUN test -n "$TENSORRT_VERSION" || (echo "No tensorrt version specified, please use --build-arg TENSORRT_VERSION=x.y.z to specify a version." && exit 1)
8+
RUN test -n "$TENSORRT_VERSION" || (echo "No tensorrt version specified, please use --build-arg TENSORRT_VERSION=x.y to specify a version." && exit 1)
99
ARG CUDNN_VERSION
1010
ENV CUDNN_VERSION=${CUDNN_VERSION}
11-
RUN test -n "$CUDNN_VERSION" || (echo "No cudnn version specified, please use --build-arg CUDNN_VERSION=x.y.z to specify a version." && exit 1)
11+
RUN test -n "$CUDNN_VERSION" || (echo "No cudnn version specified, please use --build-arg CUDNN_VERSION=x.y to specify a version." && exit 1)
1212

1313
ARG PYTHON_VERSION=3.10
1414
ENV PYTHON_VERSION=${PYTHON_VERSION}

docker/README.md

+3-3
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 and minor versions as in: `--build-arg TENSORRT_VERSION=a.b --build-arg CUDNN_VERSION=x.y`
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 and TensorRT 8.5
20+
- The example below uses CUDNN 8.8 and TensorRT 8.6
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 --build-arg CUDNN_VERSION=8.5 -f docker/Dockerfile -t torch_tensorrt:latest .
27+
DOCKER_BUILDKIT=1 docker build --build-arg TENSORRT_VERSION=8.6 --build-arg CUDNN_VERSION=8.8 -f docker/Dockerfile -t torch_tensorrt:latest .
2828
```
2929

3030
Run:

py/ci/build_whl.sh

+2-2
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

+4-4
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.dev20230314+cu117
4+
--extra-index-url https://download.pytorch.org/whl/nightly/cu118
5+
torch==2.1.0.dev20230419+cu118
6+
torchvision==0.16.0.dev20230419+cu118
77
--extra-index-url https://pypi.ngc.nvidia.com
8-
tensorrt==8.5.1.7
8+
tensorrt==8.6.0

py/setup.py

+8-2
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:
@@ -420,7 +426,7 @@ def run(self):
420426
long_description=long_description,
421427
ext_modules=ext_modules,
422428
install_requires=[
423-
"torch>=1.13.1",
429+
"torch >=2.1.dev,<2.2" if not LEGACY else "torch >=1.13.0,<2.0",
424430
],
425431
setup_requires=[],
426432
cmdclass={
@@ -449,7 +455,7 @@ def run(self):
449455
"Topic :: Software Development",
450456
"Topic :: Software Development :: Libraries",
451457
],
452-
python_requires=">=3.7",
458+
python_requires=">=3.8",
453459
include_package_data=True,
454460
package_data={
455461
"torch_tensorrt": package_data_list,

py/torch_tensorrt/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def _find_lib(name, paths):
5959

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

6565
if "LD_LIBRARY_PATH" in os.environ:

py/torch_tensorrt/fx/README.md

+4-4
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
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/test/passes/test_fuse_permute_linear_trt.py

-5
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.4.0.dev0"
2-
__cuda_version__ = "11.7"
3-
__cudnn_version__ = "8.5"
4-
__tensorrt_version__ = "8.5"
1+
__version__ = "1.5.0.dev0"
2+
__cuda_version__ = "11.8"
3+
__cudnn_version__ = "8.8"
4+
__tensorrt_version__ = "8.6"

pyproject.toml

+2-3
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)