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:

0 commit comments

Comments
 (0)