Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Upgrade main to TRT 8.6, CUDA 11.8, CuDNN 8.8, Torch Dev #1852

Merged
merged 6 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 120 additions & 59 deletions .circleci/config.yml

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ torch.jit.save(trt_ts_module, "trt_torchscript_module.ts") # save the TRT embedd
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.

- Bazel 5.2.0
- Libtorch 2.1.0.dev20230314 (built with CUDA 11.7)
- CUDA 11.7
- cuDNN 8.5.0
- TensorRT 8.5.1.7
- Libtorch 2.1.0.dev20230419 (built with CUDA 11.8)
- CUDA 11.8
- cuDNN 8.8.0
- TensorRT 8.6.0

## Prebuilt Binaries and Wheel files

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

> Make sure to add LibTorch to your LD_LIBRARY_PATH <br>
> `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/bazel-Torch-TensorRT/external/libtorch/lib`
> `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/bazel-TensorRT/external/libtorch/lib`

``` shell
bazel run //cpp/bin/torchtrtc -- $(realpath <PATH TO GRAPH>) out.ts <input-size>
Expand Down
27 changes: 11 additions & 16 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,27 @@ local_repository(
new_local_repository(
name = "cuda",
build_file = "@//third_party/cuda:BUILD",
path = "/usr/local/cuda-11.7/",
path = "/usr/local/cuda-11.8/",
)

new_local_repository(
name = "cublas",
build_file = "@//third_party/cublas:BUILD",
path = "/usr",
)
#############################################################################################################
# Tarballs and fetched dependencies (default - use in cases when building from precompiled bin and tarballs)
#############################################################################################################

http_archive(
name = "libtorch",
build_file = "@//third_party/libtorch:BUILD",
sha256 = "7c4b8754830fef23ec19c5eaf414794cee9597b435df055f5c1d0471d3e81568",
sha256 = "1a526a9cd19c1015674d26921dbb94bcd2d632a6f9c431a21c43f4e24768d834",
strip_prefix = "libtorch",
urls = ["https://download.pytorch.org/libtorch/nightly/cu117/libtorch-cxx11-abi-shared-with-deps-2.1.0.dev20230314%2Bcu117.zip"],
urls = ["https://download.pytorch.org/libtorch/nightly/cu118/libtorch-cxx11-abi-shared-with-deps-2.1.0.dev20230419%2Bcu118.zip"],
)

http_archive(
name = "libtorch_pre_cxx11_abi",
build_file = "@//third_party/libtorch:BUILD",
sha256 = "f1e64a75dd12d0ba4c8c1f61947299e0a9c50684dff64f0cfbf355aa7a13e8cf",
sha256 = "60c5912a5085a6a7073b3804b10d41d6cc054693bbeb7a45e0247050c2837bac",
strip_prefix = "libtorch",
urls = ["https://download.pytorch.org/libtorch/nightly/cu117/libtorch-shared-with-deps-2.1.0.dev20230314%2Bcu117.zip"],
urls = ["https://download.pytorch.org/libtorch/nightly/cu118/libtorch-shared-with-deps-2.1.0.dev20230419%2Bcu118.zip"],
)

# Download these tarballs manually from the NVIDIA website
Expand All @@ -76,20 +71,20 @@ http_archive(
http_archive(
name = "cudnn",
build_file = "@//third_party/cudnn/archive:BUILD",
sha256 = "5454a6fd94f008728caae9adad993c4e85ef36302e26bce43bea7d458a5e7b6d",
strip_prefix = "cudnn-linux-x86_64-8.5.0.96_cuda11-archive",
sha256 = "36fff137153ef73e6ee10bfb07f4381240a86fb9fb78ce372414b528cbab2293",
strip_prefix = "cudnn-linux-x86_64-8.8.0.121_cuda11-archive",
urls = [
"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",
"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",
],
)

http_archive(
name = "tensorrt",
build_file = "@//third_party/tensorrt/archive:BUILD",
sha256 = "39cc7f077057d1363794e8ff51c4cf21a5dbeccf1116b0020ba0dae0f3063076",
strip_prefix = "TensorRT-8.5.1.7",
sha256 = "c1732a1093c57ab79fa0b687f061be369e449c9c17792b660f3663ecd8fa7b63",
strip_prefix = "TensorRT-8.6.0.12",
urls = [
"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",
"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",
],
)

Expand Down
2 changes: 1 addition & 1 deletion core/runtime/TRTEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ TRTEngine::TRTEngine(
}

TRTEngine::~TRTEngine() {
rt.reset();
trt_engine_profiler.reset();
exec_ctx.reset();
cuda_engine.reset();
rt.reset();
}

void TRTEngine::disable_profiling() {
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/torch_tensorrt/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define STR(x) XSTR(x)

#define TORCH_TENSORRT_MAJOR_VERSION 1
#define TORCH_TENSORRT_MINOR_VERSION 3
#define TORCH_TENSORRT_MINOR_VERSION 5
#define TORCH_TENSORRT_PATCH_VERSION 0
#define TORCH_TENSORRT_VERSION \
STR(TORCH_TENSORRT_MAJOR_VERSION) \
Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Base image starts with CUDA
ARG BASE_IMG=nvidia/cuda:11.7.1-devel-ubuntu22.04
ARG BASE_IMG=nvidia/cuda:11.8.0-devel-ubuntu22.04
FROM ${BASE_IMG} as base
ENV BASE_IMG=nvidia/cuda:11.7.1-devel-ubuntu22.04
ENV BASE_IMG=nvidia/cuda:11.8.0-devel-ubuntu22.04

ARG TENSORRT_VERSION
ENV TENSORRT_VERSION=${TENSORRT_VERSION}
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)
RUN test -n "$TENSORRT_VERSION" || (echo "No tensorrt version specified, please use --build-arg TENSORRT_VERSION=x.y to specify a version." && exit 1)
ARG CUDNN_VERSION
ENV CUDNN_VERSION=${CUDNN_VERSION}
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)
RUN test -n "$CUDNN_VERSION" || (echo "No cudnn version specified, please use --build-arg CUDNN_VERSION=x.y to specify a version." && exit 1)

ARG PYTHON_VERSION=3.10
ENV PYTHON_VERSION=${PYTHON_VERSION}
Expand Down
6 changes: 3 additions & 3 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* 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>.
* 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`
* [**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
* [**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
* [**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.

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

### Instructions

- The example below uses CUDNN 8.5 and TensorRT 8.5
- The example below uses CUDNN 8.8 and TensorRT 8.6
- See <a href="https://github.com/pytorch/TensorRT#dependencies">dependencies</a> for a list of current default dependencies.

> From root of Torch-TensorRT repo

Build:
```
DOCKER_BUILDKIT=1 docker build --build-arg TENSORRT_VERSION=8.5 --build-arg CUDNN_VERSION=8.5 -f docker/Dockerfile -t torch_tensorrt:latest .
DOCKER_BUILDKIT=1 docker build --build-arg TENSORRT_VERSION=8.6 --build-arg CUDNN_VERSION=8.8 -f docker/Dockerfile -t torch_tensorrt:latest .
```

Run:
Expand Down
4 changes: 2 additions & 2 deletions py/ci/build_whl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Example usage: docker run -it -v$(pwd)/..:/workspace/TRTorch build_trtorch_wheel /bin/bash /workspace/TRTorch/py/build_whl.sh

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

cp -r $CUDA_HOME /usr/local/cuda
Expand Down Expand Up @@ -108,4 +108,4 @@ libtorchtrt_pre_cxx11_abi() {
CUDNN_VERSION=$(cd ${PROJECT_DIR}/py && ${PY_DIR}/bin/python3 -c "from versions import __cudnn_version__;print(__cudnn_version__)")
TORCH_VERSION=$(${PY_DIR}/bin/python -c "from torch import __version__;print(__version__.split('+')[0])")
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
}
}
8 changes: 4 additions & 4 deletions py/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
numpy
packaging
pybind11==2.6.2
--extra-index-url https://download.pytorch.org/whl/nightly/cu117
torch==2.1.0.dev20230314+cu117
torchvision==0.15.0.dev20230314+cu117
--extra-index-url https://download.pytorch.org/whl/nightly/cu118
torch==2.1.0.dev20230419+cu118
torchvision==0.16.0.dev20230419+cu118
--extra-index-url https://pypi.ngc.nvidia.com
tensorrt==8.5.1.7
tensorrt==8.6.0
10 changes: 8 additions & 2 deletions py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

FX_ONLY = False

LEGACY = False

RELEASE = False

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

if "--legacy" in sys.argv:
LEGACY = True
sys.argv.remove("--legacy")

if "--release" not in sys.argv:
__version__ = __version__ + "+" + get_git_revision_short_hash()
else:
Expand Down Expand Up @@ -420,7 +426,7 @@ def run(self):
long_description=long_description,
ext_modules=ext_modules,
install_requires=[
"torch>=1.13.1",
"torch >=2.1.dev,<2.2" if not LEGACY else "torch >=1.13.0,<2.0",
],
setup_requires=[],
cmdclass={
Expand Down Expand Up @@ -449,7 +455,7 @@ def run(self):
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
],
python_requires=">=3.7",
python_requires=">=3.8",
include_package_data=True,
package_data={
"torch_tensorrt": package_data_list,
Expand Down
2 changes: 1 addition & 1 deletion py/torch_tensorrt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _find_lib(name, paths):

elif sys.platform.startswith("linux"):
LINUX_PATHS = [
"/usr/local/cuda/lib64",
"/usr/local/cuda-11.8/lib64",
]

if "LD_LIBRARY_PATH" in os.environ:
Expand Down
8 changes: 4 additions & 4 deletions py/torch_tensorrt/fx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ FX2TRT is merged as FX module in Torch-TensorRT
```
$ conda create --name python_env python=3.8
$ conda activate python_env
# Recommend to install PyTorch 1.12 and later
$ conda install pytorch torchvision torchtext cudatoolkit=11.3 -c pytorch-nightly
# Recommend to install PyTorch 2.0 and later
$ conda install pytorch torchvision torchtext cudatoolkit=11.8 -c pytorch-nightly
# Install TensorRT python package
$ pip3 install nvidia-pyindex
$ pip3 install tensorrt==8.5.1.7
$ pip3 install tensorrt==8.6.0
$ git clone https://github.com/pytorch/TensorRT.git
$ cd TensorRT/py && python setup.py install --fx-only && cd ..
$ pyton -c "import torch_tensorrt.fx"
$ python -c "import torch_tensorrt.fx"
# Test an example by
$ python py/torch_tensorrt/fx/example/lower_example.py
```
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ def forward(self, x):
apply_passes=[fuse_permute_linear],
)

# TODO: The following test has been disabled due to a bug in TRT 8.5.1.7
# with self.linear2. Issue : https://github.com/pytorch/TensorRT/issues/1444
@unittest.skip(
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"
)
def test_multi_fuse_permute_linear(self):
"""
Fusion when permute output is shared by multiple linears
Expand Down
8 changes: 4 additions & 4 deletions py/versions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.4.0.dev0"
__cuda_version__ = "11.7"
__cudnn_version__ = "8.5"
__tensorrt_version__ = "8.5"
__version__ = "1.5.0.dev0"
__cuda_version__ = "11.8"
__cudnn_version__ = "8.8"
__tensorrt_version__ = "8.6"
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ requires = [
"cffi",
"typing_extensions",
"future",
"nvidia-pyindex",
"nvidia-tensorrt==8.4.3.1"
"tensorrt >=8.6,<8.7"
]

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