diff --git a/.circleci/config.yml b/.circleci/config.yml index 77a1fd036f..0391ac16f2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -155,18 +155,38 @@ commands: platform: type: string default: "x86_64" + release: + type: boolean + default: false steps: - run: - name: Build torch-tensorrt python release + name: Build setup command: | - mv toolchains/ci_workspaces/WORKSPACE.<< parameters.platform >> WORKSPACE - cd py + mv ~/project/toolchains/ci_workspaces/WORKSPACE.<< parameters.platform >> ~/project/WORKSPACE python3 -m pip install wheel setuptools python3 -m pip install pybind11==2.6.2 - python3 setup.py bdist_wheel --use-cxx11-abi - python3 setup.py install --use-cxx11-abi - mkdir -p /tmp/dist/builds - cp dist/* /tmp/dist/builds + - when: + condition: << parameters.release >> + steps: + - run: + name: Build torch-tensorrt python release package + command: | + cd ~/project/py + python3 setup.py bdist_wheel --use-cxx11-abi --release + python3 setup.py install --use-cxx11-abi --release + mkdir -p /tmp/dist/builds + cp dist/* /tmp/dist/builds + - unless: + condition: << parameters.release >> + steps: + - run: + name: Build torch-tensorrt python package + command: | + cd ~/project/py + python3 setup.py bdist_wheel --use-cxx11-abi + python3 setup.py install --use-cxx11-abi + mkdir -p /tmp/dist/builds + cp dist/* /tmp/dist/builds build-py-fx-only: description: "Build the torch-tensorrt python release with only the fx backend" @@ -579,6 +599,150 @@ jobs: - dump-test-env - test-fx + package-x86_64: + parameters: + enabled: + type: boolean + default: false + torch-build: + type: string + torch-build-index: + type: string + machine: + image: ubuntu-2004-cuda-11.4:202110-01 + resource_class: xlarge + steps: + - when: + condition: << parameters.enabled >> + steps: + - checkout + - run: + name: "Build packaging container" + command: | + cd ~/project/py/ + docker build -t torch_tensorrt_release_env --build-arg trt_version=<< pipeline.parameters.trt-release-version-short >> -f ci/Dockerfile.ci . + - run: + name: Build Python packages and pre-cxx11-abi tarball + command: | + cd ~/project/py/ + cp ~/project/toolchains/ci_workspaces/WORKSPACE.x86_64.release.rhel ~/project/WORKSPACE + docker run -it --rm -v ~/project:/workspace/project torch_tensorrt_release_env /bin/bash /workspace/project/py/ci/build_whl.sh + - create-env: + os: "ubuntu2004" + platform: "x86_64" + cudnn-version: << pipeline.parameters.cudnn-release-version >> + trt-version-short: << pipeline.parameters.trt-release-version-short >> + bazel-version: "5.1.1" + bazel-platform: "x86_64" + - run: + name: Build cxx11-abi tarball + command: | + set -e + cd ~/project/ + cp ~/project/toolchains/ci_workspaces/WORKSPACE.x86_64.release.ubuntu ~/project/WORKSPACE + bazel build //:libtorchtrt -c opt --noshow_progress + sudo chown -R $(whoami) ~/project/py + CUDA_VERSION=$(cd ~/project/py/torch_tensorrt && python3 -c "from _version import __cuda_version__;print(__cuda_version__)") + TORCHTRT_VERSION=$(cd ~/project/py/torch_tensorrt && python3 -c "from _version import __version__;print(__version__)") + TRT_VERSION=$(cd ~/project/py/torch_tensorrt && python3 -c "from _version import __tensorrt_version__;print(__tensorrt_version__)") + CUDNN_VERSION=$(cd ~/project/py/torch_tensorrt && python3 -c "from _version import __cudnn_version__;print(__cudnn_version__)") + pip3 install -r ~/project/py/requirements.txt + TORCH_VERSION=$(python3 -c "from torch import __version__;print(__version__.split('+')[0])") + cp ~/project/bazel-bin/libtorchtrt.tar.gz ~/project/py/dist/libtorchtrt-${TORCHTRT_VERSION}-cudnn${CUDNN_VERSION}-tensorrt${TRT_VERSION}-cuda${CUDA_VERSION}-libtorch${TORCH_VERSION}-x86_64-linux.tar.gz + - run: + name: Collect packages + command: | + mkdir -p /tmp/dist/release + cp -r ~/project/py/dist/* /tmp/dist/release + - store_artifacts: + path: /tmp/dist/release + destination: x86_64-release-pkgs + - unless: + condition: << parameters.enabled >> + steps: + - run: + name: Skipped packaging + command: echo -e "Packaging stage not enabled" + + package-jetson: + parameters: + enabled: + type: boolean + default: true + torch-build: + type: string + jetpack-version: + type: string + cxx11-abi: + type: boolean + default: true + python-version: + type: string + default: 3.8.10 + machine: + image: ubuntu-2004:202201-02 + resource_class: arm.xlarge + steps: + - checkout + #- run: + # name: Upgrade base + # command: | + # sudo apt clean + # sudo apt update + # sudo apt upgrade + # sudo apt install software-properties-common + - install-cuda: + os: "ubuntu2004" + platform: "sbsa" + cuda-pkg-name: "cuda-toolkit-11-4" + - run: + name: Install openblas + command: sudo apt install libopenblas-dev + - create-env: + os: "ubuntu2004" + platform: "sbsa" + cudnn-version: << pipeline.parameters.cudnn-jetson-version >> + trt-version-short: << pipeline.parameters.trt-jetson-version-short >> + bazel-version: "5.1.1" + bazel-platform: "arm64" + - run: + name: Set python version + command: | + pyenv install << parameters.python-version >> + pyenv global << parameters.python-version >> + - run: + name: Install NGC Torch + environment: + TORCH_INSTALL: https://developer.download.nvidia.com/compute/redist/jp/v<< parameters.jetpack-version >>/pytorch/<< parameters.torch-build >> + command: | + set -e + python3 -m pip install --upgrade pip; python3 -m pip install setuptools wheel; python3 -m pip install expecttest xmlrunner hypothesis aiohttp numpy=='1.19.4' pyyaml scipy=='1.5.3' ninja cython typing_extensions protobuf; export "LD_LIBRARY_PATH=/usr/lib/llvm-8/lib:$LD_LIBRARY_PATH"; python3 -m pip install --upgrade protobuf; python3 -m pip install --no-cache $TORCH_INSTALL + - build-py-cxx11-abi: + platform: "sbsa" + release: true + - run: + name: Build cxx11-abi tarball + command: | + set -e + cd ~/project/py/ + bazel build //:libtorchtrt -c opt --noshow_progress + CUDA_VERSION=$(cd torch_tensorrt && python3 -c "from _version import __cuda_version__;print(__cuda_version__)") + TORCHTRT_VERSION=$(cd torch_tensorrt && python3 -c "from _version import __version__;print(__version__)") + TRT_VERSION=$(cd torch_tensorrt && python3 -c "from _version import __tensorrt_version__;print(__tensorrt_version__)") + CUDNN_VERSION=$(cd torch_tensorrt && python3 -c "from _version import __cudnn_version__;print(__cudnn_version__)") + pip3 install -r ~/project/py/requirements.txt + TORCH_VERSION=$(python3 -c "from torch import __version__;print(__version__.split('+')[0])") + cp ~/project/bazel-bin/libtorchtrt.tar.gz ~/project/py/dist/libtorchtrt-${TORCHTRT_VERSION}-cudnn${CUDNN_VERSION}-tensorrt${TRT_VERSION}-cuda${CUDA_VERSION}-libtorch${TORCH_VERSION}-aarch64-linux-jp<< parameters.jetpack-version >>.tar.gz + - run: + name: Move to release dir + command: | + mkdir -p /tmp/dist/jetson + cp -r ~/project/py/dist/* /tmp/dist/jetson + - store_artifacts: + path: /tmp/dist/jetson + destination: aarch64-release-pkgs + + parameters: # Nightly platform config torch-nightly-build: @@ -631,6 +795,10 @@ parameters: type: string default: "8.4.1.5" + enable-packaging: + type: boolean + default: false + # Invoke jobs via workflows # See: https://circleci.com/docs/2.0/configuration-reference/#workflows workflows: @@ -642,6 +810,7 @@ workflows: branches: only: - master + - release/**/* jobs: - build-aarch64-pyt-jetson: torch-build: << pipeline.parameters.torch-jetson-build >> @@ -649,7 +818,6 @@ workflows: python-version: 3.8.10 - - build-x86_64-pyt-release: torch-build: << pipeline.parameters.torch-release-build >> torch-build-index: << pipeline.parameters.torch-release-build-index >> @@ -674,7 +842,7 @@ workflows: requires: - build-x86_64-pyt-release - - test-py-ts-x86_64: + - test-py-fx-x86_64: name: test-py-fx-x86_64-pyt-release channel: "release" torch-build: << pipeline.parameters.torch-release-build >> @@ -684,8 +852,6 @@ workflows: - build-x86_64-pyt-release - - - build-x86_64-pyt-nightly: torch-build: << pipeline.parameters.torch-nightly-build >> torch-build-index: << pipeline.parameters.torch-nightly-build-index >> @@ -719,13 +885,74 @@ workflows: requires: - build-x86_64-pyt-nightly - on-push: + release: + when: << pipeline.parameters.enable-packaging >> jobs: - build-aarch64-pyt-jetson: torch-build: << pipeline.parameters.torch-jetson-build >> jetpack-version: << pipeline.parameters.jetpack-version >> python-version: 3.8.10 + - build-x86_64-pyt-release: + torch-build: << pipeline.parameters.torch-release-build >> + torch-build-index: << pipeline.parameters.torch-release-build-index >> + + + - test-core-cpp-x86_64: + name: test-core-cpp-x86_64-pyt-release + channel: "release" + torch-build: << pipeline.parameters.torch-release-build >> + torch-build-index: << pipeline.parameters.torch-release-build-index >> + trt-version-short: << pipeline.parameters.trt-release-version-short >> + trt-version-long: << pipeline.parameters.trt-release-version-long >> + cudnn-version: << pipeline.parameters.cudnn-release-version >> + requires: + - build-x86_64-pyt-release + + - test-py-ts-x86_64: + name: test-py-ts-x86_64-pyt-release + channel: "release" + torch-build: << pipeline.parameters.torch-release-build >> + torch-build-index: << pipeline.parameters.torch-release-build-index >> + trt-version-long: << pipeline.parameters.trt-release-version-long >> + requires: + - build-x86_64-pyt-release + + - test-py-fx-x86_64: + name: test-py-fx-x86_64-pyt-release + channel: "release" + torch-build: << pipeline.parameters.torch-release-build >> + torch-build-index: << pipeline.parameters.torch-release-build-index >> + trt-version-long: << pipeline.parameters.trt-release-version-long >> + requires: + - build-x86_64-pyt-release + + + - package-x86_64: + name: package-release-x86_64 + enabled: << pipeline.parameters.enable-packaging >> + torch-build: << pipeline.parameters.torch-release-build >> + torch-build-index: << pipeline.parameters.torch-release-build-index >> + requires: + - test-core-cpp-x86_64-pyt-release + - test-py-ts-x86_64-pyt-release + - test-py-fx-x86_64-pyt-release + + - package-jetson: + name: package-release-aarch64-jetson + enabled: << pipeline.parameters.enable-packaging >> + torch-build: << pipeline.parameters.torch-jetson-build >> + jetpack-version: << pipeline.parameters.jetpack-version >> + python-version: 3.8.10 + requires: + - build-aarch64-pyt-jetson + + on-push: + jobs: + - build-aarch64-pyt-jetson: + torch-build: << pipeline.parameters.torch-jetson-build >> + jetpack-version: << pipeline.parameters.jetpack-version >> + python-version: 3.8.10 - build-x86_64-pyt-release: @@ -752,7 +979,7 @@ workflows: requires: - build-x86_64-pyt-release - - test-py-ts-x86_64: + - test-py-fx-x86_64: name: test-py-fx-x86_64-pyt-release channel: "release" torch-build: << pipeline.parameters.torch-release-build >> @@ -762,7 +989,6 @@ workflows: - build-x86_64-pyt-release - - build-x86_64-pyt-nightly: torch-build: << pipeline.parameters.torch-nightly-build >> torch-build-index: << pipeline.parameters.torch-nightly-build-index >> @@ -794,5 +1020,4 @@ workflows: torch-build-index: << pipeline.parameters.torch-nightly-build-index >> trt-version-long: << pipeline.parameters.trt-nightly-version-long >> requires: - - build-x86_64-pyt-nightly - + - build-x86_64-pyt-nightly \ No newline at end of file diff --git a/core/conversion/converters/impl/max.cpp b/core/conversion/converters/impl/max.cpp index 1f03b97260..175cc75461 100644 --- a/core/conversion/converters/impl/max.cpp +++ b/core/conversion/converters/impl/max.cpp @@ -29,8 +29,8 @@ auto max_registrations TORCHTRT_UNUSED = RegisterNodeConversionPatterns().patter TORCHTRT_CHECK(topk_layer, "Unable to create max layer from node: " << *n); auto topk_dims = util::toVec(topk_layer->getOutput(0)->getDimensions()); - nvinfer1::ITensor* out0; - nvinfer1::ITensor* out1; + nvinfer1::ITensor* out0 = nullptr; + nvinfer1::ITensor* out1 = nullptr; if (!keep_dims) { if (topk_dims[dim] == 1) { auto squeeze_layer = ctx->net->addShuffle(*topk_layer->getOutput(0)); diff --git a/py/build_whl.sh b/py/build_whl.sh index cbae94220e..38de2aa02b 100755 --- a/py/build_whl.sh +++ b/py/build_whl.sh @@ -31,7 +31,14 @@ build_py310() { #auditwheel repair --plat manylinux2014_x86_64 } +#build_py311() { +# /opt/python/cp311-cp311/bin/python -m pip install -r requirements.txt +# /opt/python/cp311-cp311/bin/python setup.py bdist_wheel --release + #auditwheel repair --plat manylinux2014_x86_64 +#} + build_py37 build_py38 build_py39 build_py310 +#build_py311 diff --git a/py/ci/Dockerfile.ci b/py/ci/Dockerfile.ci new file mode 100644 index 0000000000..ba887a9678 --- /dev/null +++ b/py/ci/Dockerfile.ci @@ -0,0 +1,14 @@ +FROM pytorch/manylinux-builder:cuda11.3 +ARG trt_version + +RUN echo -e "Installing with TensorRT ${trt_version}" + +RUN yum install -y ninja-build tensorrt-${trt_version}.* + +RUN wget https://github.com/bazelbuild/bazelisk/releases/download/v1.11.0/bazelisk-linux-amd64 \ + && mv bazelisk-linux-amd64 /usr/bin/bazel \ + && chmod +x /usr/bin/bazel + +RUN mkdir /workspace + +WORKDIR /workspace \ No newline at end of file diff --git a/py/ci/build_whl.sh b/py/ci/build_whl.sh new file mode 100755 index 0000000000..f25bebf194 --- /dev/null +++ b/py/ci/build_whl.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# Example usage: docker run -it -v$(pwd)/..:/workspace/TRTorch build_trtorch_wheel /bin/bash /workspace/TRTorch/py/build_whl.sh + +cd /workspace/project/py + +export CXX=g++ +export CUDA_HOME=/usr/local/cuda-11.3 +PROJECT_DIR=/workspace/project + +cp -r $CUDA_HOME /usr/local/cuda + +build_py37() { + /opt/python/cp37-cp37m/bin/python -m pip install -r requirements.txt + /opt/python/cp37-cp37m/bin/python setup.py bdist_wheel --release --ci + #auditwheel repair --plat manylinux2014_x86_64 +} + +build_py38() { + /opt/python/cp38-cp38/bin/python -m pip install -r requirements.txt + /opt/python/cp38-cp38/bin/python setup.py bdist_wheel --release --ci + #auditwheel repair --plat manylinux2014_x86_64 +} + +build_py39() { + /opt/python/cp39-cp39/bin/python -m pip install -r requirements.txt + /opt/python/cp39-cp39/bin/python setup.py bdist_wheel --release --ci + #auditwheel repair --plat manylinux2014_x86_64 +} + +build_py310() { + /opt/python/cp310-cp310/bin/python -m pip install -r requirements.txt + /opt/python/cp310-cp310/bin/python setup.py bdist_wheel --release --ci + #auditwheel repair --plat manylinux2014_x86_64 +} + +#build_py311() { +# /opt/python/cp311-cp311/bin/python -m pip install -r requirements.txt +# /opt/python/cp311-cp311/bin/python setup.py bdist_wheel --release --ci +# #auditwheel repair --plat manylinux2014_x86_64 +#} + +build_libtorchtrt() { + bazel clean + bazel build //:libtorchtrt --platforms //toolchains:ci_rhel_x86_64_linux -c opt --noshow_progress + CUDA_VERSION=$(cd ${PROJECT_DIR}/py/torch_tensorrt && python3 -c "from _version import __cuda_version__;print(__cuda_version__)") + TORCHTRT_VERSION=$(cd ${PROJECT_DIR}/py/torch_tensorrt && python3 -c "from _version import __version__;print(__version__)") + TRT_VERSION=$(cd ${PROJECT_DIR}/py/torch_tensorrt && python3 -c "from _version import __tensorrt_version__;print(__tensorrt_version__)") + CUDNN_VERSION=$(cd ${PROJECT_DIR}/py/torch_tensorrt && python3 -c "from _version import __cudnn_version__;print(__cudnn_version__)") + TORCH_VERSION=$(/opt/python/cp310-cp310/bin/python -c "from torch import __version__;print(__version__.split('+')[0])") + cp ${PROJECT_DIR}/bazel-bin/libtorchtrt.tar.gz ${PROJECT_DIR}/py/dist/libtorchtrt-${TORCHTRT_VERSION}-cudnn${CUDNN_VERSION}-tensorrt${TRT_VERSION}-cuda${CUDA_VERSION}-libtorch${TORCH_VERSION}-x86_64-linux.tar.gz +} + +build_libtorchtrt_pre_cxx11_abi() { + bazel build //:libtorchtrt --config pre_cxx11_abi --platforms //toolchains:ci_rhel_x86_64_linux -c opt --noshow_progress + CUDA_VERSION=$(cd ${PROJECT_DIR}/py/torch_tensorrt && python3 -c "from _version import __cuda_version__;print(__cuda_version__)") + TORCHTRT_VERSION=$(cd ${PROJECT_DIR}/py/torch_tensorrt && python3 -c "from _version import __version__;print(__version__)") + TRT_VERSION=$(cd ${PROJECT_DIR}/py/torch_tensorrt && python3 -c "from _version import __tensorrt_version__;print(__tensorrt_version__)") + CUDNN_VERSION=$(cd ${PROJECT_DIR}/py/torch_tensorrt && python3 -c "from _version import __cudnn_version__;print(__cudnn_version__)") + TORCH_VERSION=$(/opt/python/cp310-cp310/bin/python -c "from torch import __version__;print(__version__.split('+')[0])") + cp ${PROJECT_DIR}/bazel-bin/libtorchtrt.tar.gz ${PROJECT_DIR}/py/dist/libtorchtrt-${TORCHTRT_VERSION}-pre-cxx11-abi-cudnn${CUDNN_VERSION}-tensorrt${TRT_VERSION}-cuda${CUDA_VERSION}-libtorch${TORCH_VERSION}-x86_64-linux.tar.gz +} + +build_py37 +build_py38 +build_py39 +build_py310 +#build_py311 +build_libtorchtrt_pre_cxx11_abi +#build_libtorchtrt \ No newline at end of file diff --git a/py/requirements.txt b/py/requirements.txt index 2f49390911..29bd0f92eb 100644 --- a/py/requirements.txt +++ b/py/requirements.txt @@ -1,3 +1,3 @@ --extra-index-url https://download.pytorch.org/whl/cu113 -torch==1.12.0+cu113 +torch==1.12.0 pybind11==2.6.2 diff --git a/py/setup.py b/py/setup.py index f11e348b02..7e9f32df87 100644 --- a/py/setup.py +++ b/py/setup.py @@ -24,10 +24,14 @@ FX_ONLY = False +RELEASE = False + +CI_RELEASE = False + __version__ = '1.2.0a0' __cuda_version__ = '11.3' -__cudnn_version__ = '8.2' -__tensorrt_version__ = '8.2' +__cudnn_version__ = '8.4' +__tensorrt_version__ = '8.4' def get_git_revision_short_hash() -> str: return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() @@ -39,8 +43,14 @@ def get_git_revision_short_hash() -> str: if "--release" not in sys.argv: __version__ = __version__ + "+" + get_git_revision_short_hash() else: + RELEASE = True sys.argv.remove("--release") +if "--ci" in sys.argv: + sys.argv.remove("--ci") + if RELEASE: + CI_RELEASE = True + if "--use-cxx11-abi" in sys.argv: sys.argv.remove("--use-cxx11-abi") CXX11_ABI = True @@ -111,6 +121,10 @@ def build_libtorchtrt_pre_cxx11_abi(develop=True, use_dist_dir=True, cxx11_abi=F cmd.append("--platforms=//toolchains:jetpack_4.6") print("Jetpack version: >=4.6") + if CI_RELEASE: + cmd.append("--platforms=//toolchains:ci_rhel_x86_64_linux") + print("CI based build") + print("building libtorchtrt") status_code = subprocess.run(cmd).returncode diff --git a/third_party/cudnn/local/BUILD b/third_party/cudnn/local/BUILD index c2ef7c6f60..6433f33eaa 100644 --- a/third_party/cudnn/local/BUILD +++ b/third_party/cudnn/local/BUILD @@ -8,6 +8,15 @@ config_setting( ], ) +config_setting( + name = "ci_rhel_x86_64_linux", + constraint_values = [ + "@platforms//cpu:x86_64", + "@platforms//os:linux", + "@//toolchains/distro:ci_rhel" + ] +) + config_setting( name = "windows", constraint_values = [ @@ -30,6 +39,7 @@ cc_import( shared_library = select({ ":aarch64_linux": "lib/aarch64-linux-gnu/libcudnn.so", ":windows": "bin/cudnn64_7.dll", #Need to configure specific version for windows + ":ci_rhel_x86_64_linux": "lib64/libcudnn.so", "//conditions:default": "lib/x86_64-linux-gnu/libcudnn.so", }), visibility = ["//visibility:private"], diff --git a/third_party/tensorrt/local/BUILD b/third_party/tensorrt/local/BUILD index 7b4fcc2841..1954b00df7 100644 --- a/third_party/tensorrt/local/BUILD +++ b/third_party/tensorrt/local/BUILD @@ -15,6 +15,15 @@ config_setting( ], ) +config_setting( + name = "ci_rhel_x86_64_linux", + constraint_values = [ + "@platforms//cpu:x86_64", + "@platforms//os:linux", + "@//toolchains/distro:ci_rhel" + ] +) + cc_library( name = "nvinfer_headers", hdrs = select({ @@ -29,6 +38,17 @@ cc_library( "include/aarch64-linux-gnu/NvInferPluginUtils.h", ], ), + ":ci_rhel_x86_64_linux": [ + "include/NvUtils.h", + ] + glob( + [ + "include/NvInfer*.h", + ], + exclude = [ + "include/NvInferPlugin.h", + "include/NvInferPluginUtils.h", + ], + ), ":windows": [ "include/NvUtils.h", ] + glob( @@ -55,6 +75,7 @@ cc_library( includes = select({ ":aarch64_linux": ["include/aarch64-linux-gnu"], ":windows": ["include/"], + ":ci_rhel_x86_64_linux": ["include/"], "//conditions:default": ["include/x86_64-linux-gnu/"], }), visibility = ["//visibility:private"], @@ -65,6 +86,7 @@ cc_import( static_library = select({ ":aarch64_linux": "lib/aarch64-linux-gnu/libnvinfer_static.a", ":windows": "lib/nvinfer.lib", + ":ci_rhel_x86_64_linux": "lib64/libnvinfer_static.a", "//conditions:default": "lib/x86_64-linux-gnu/libnvinfer_static.a", }), visibility = ["//visibility:private"], @@ -75,6 +97,7 @@ cc_import( shared_library = select({ ":aarch64_linux": "lib/aarch64-linux-gnu/libnvinfer.so", ":windows": "lib/nvinfer.dll", + ":ci_rhel_x86_64_linux": "lib64/libnvinfer.so", "//conditions:default": "lib/x86_64-linux-gnu/libnvinfer.so", }), visibility = ["//visibility:private"], @@ -101,6 +124,7 @@ cc_import( shared_library = select({ ":aarch64_linux": "lib/aarch64-linux-gnu/libnvparsers.so", ":windows": "lib/nvparsers.dll", + ":ci_rhel_x86_64_linux": "lib64/libnvparsers.so", "//conditions:default": "lib/x86_64-linux-gnu/libnvparsers.so", }), visibility = ["//visibility:private"], @@ -122,6 +146,13 @@ cc_library( "include/NvOnnxParserRuntime.h", "include/NvOnnxConfig.h", "include/NvUffParser.h", + ], + ":ci_rhel_x86_64_linux": [ + "include/NvCaffeParser.h", + "include/NvOnnxParser.h", + "include/NvOnnxParserRuntime.h", + "include/NvOnnxConfig.h", + "include/NvUffParser.h", ], "//conditions:default": [ "include/x86_64-linux-gnu/NvCaffeParser.h", @@ -134,6 +165,7 @@ cc_library( includes = select({ ":aarch64_linux": ["include/aarch64-linux-gnu"], ":windows": ["include/"], + ":ci_rhel_x86_64_linux": ["include/"], "//conditions:default": ["include/x86_64-linux-gnu/"], }), visibility = ["//visibility:private"], @@ -156,6 +188,7 @@ cc_import( shared_library = select({ ":aarch64_linux": "lib/aarch64-linux-gnu/libnvonnxparser.so", ":windows": "lib/nvonnxparser.dll", + ":ci_rhel_x86_64_linux": "lib64/libnvonnxparser.so", "//conditions:default": "lib/x86_64-linux-gnu/libnvonnxparser.so", }), visibility = ["//visibility:private"], @@ -174,6 +207,11 @@ cc_library( "include/NvOnnxParserRuntime.h", "include/NvOnnxConfig.h", ], + ":ci_rhel_x86_64_linux": [ + "include/NvOnnxParser.h", + "include/NvOnnxParserRuntime.h", + "include/NvOnnxConfig.h", + ], "//conditions:default": [ "include/x86_64-linux-gnu/NvOnnxParser.h", "include/x86_64-linux-gnu/NvOnnxParserRuntime.h", @@ -183,6 +221,7 @@ cc_library( includes = select({ ":aarch64_linux": ["include/aarch64-linux-gnu"], ":windows": ["include/"], + ":ci_rhel_x86_64_linux": ["include/"], "//conditions:default": ["include/x86_64-linux-gnu/"], }), visibility = ["//visibility:private"], @@ -205,6 +244,7 @@ cc_import( shared_library = select({ ":aarch64_linux": "lib/x86_64-linux-gnu/libnvonnxparser_runtime.so", ":windows": "lib/nvonnxparser_runtime.dll", + ":ci_rhel_x86_64_linux": "lib64/libnvonnxparser_runtime.so", "//conditions:default": "lib/x86_64-linux-gnu/libnvonnxparser_runtime.so", }), visibility = ["//visibility:public"], @@ -219,6 +259,9 @@ cc_library( ":windows": [ "include/NvOnnxParserRuntime.h", ], + ":ci_rhel_x86_64_linux": [ + "include/NvOnnxParserRuntime.h", + ], "//conditions:default": [ "include/x86_64-linux-gnu/NvOnnxParserRuntime.h", ], @@ -226,6 +269,7 @@ cc_library( includes = select({ ":aarch64_linux": ["include/aarch64-linux-gnu"], ":windows": ["include/"], + ":ci_rhel_x86_64_linux": ["include/"], "//conditions:default": ["include/x86_64-linux-gnu/"], }), visibility = ["//visibility:private"], @@ -248,6 +292,7 @@ cc_import( shared_library = select({ ":aarch64_linux": "lib/aarch64-linux-gnu/libnvcaffe_parsers.so", ":windows": "lib/nvcaffe_parsers.dll", + ":ci_rhel_x86_64_linux": "lib64/libnvcaffe_parsers.so", "//conditions:default": "lib/x86_64-linux-gnu/libnvcaffe_parsers.so", }), visibility = ["//visibility:private"], @@ -262,13 +307,17 @@ cc_library( ":windows": [ "include/NvCaffeParser.h", ], + ":ci_rhel_x86_64_linux": [ + "include/NvOnnxParserRuntime.h", + ], "//conditions:default": [ "include/x86_64-linux-gnu/NvCaffeParser.h", - ], + ] }), includes = select({ ":aarch64_linux": ["include/aarch64-linux-gnu"], ":windows": ["include/"], + ":ci_rhel_x86_64_linux": ["include/"], "//conditions:default": ["include/x86_64-linux-gnu/"], }), visibility = ["//visibility:private"], @@ -291,16 +340,19 @@ cc_library( hdrs = select({ ":aarch64_linux": glob(["include/aarch64-linux-gnu/NvInferPlugin*.h"]), ":windows": glob(["include/NvInferPlugin*.h"]), + ":ci_rhel_x86_64_linux": glob(["include/NvInferPlugin*.h"]), "//conditions:default": glob(["include/x86_64-linux-gnu/NvInferPlugin*.h"]), }), srcs = select({ ":aarch64_linux": ["lib/aarch64-linux-gnu/libnvinfer_plugin.so"], ":windows": ["lib/nvinfer_plugin.dll"], + ":ci_rhel_x86_64_linux": glob(["lib64/libnvinfer_plugin.so"]), "//conditions:default": ["lib/x86_64-linux-gnu/libnvinfer_plugin.so"], }), includes = select({ ":aarch64_linux": ["include/aarch64-linux-gnu/"], ":windows": ["include/"], + ":ci_rhel_x86_64_linux": ["include/"], "//conditions:default": ["include/x86_64-linux-gnu/"], }), deps = [ diff --git a/toolchains/BUILD b/toolchains/BUILD index 2791844032..3d61043eea 100644 --- a/toolchains/BUILD +++ b/toolchains/BUILD @@ -25,3 +25,12 @@ platform( "@//toolchains/jetpack:4.6" ] ) + +platform( + name = "ci_rhel_x86_64_linux", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + "@//toolchains/distro:ci_rhel" + ] +) diff --git a/toolchains/ci_workspaces/WORKSPACE.sbsa b/toolchains/ci_workspaces/WORKSPACE.sbsa index 93cf5876a7..cf45a596c3 100644 --- a/toolchains/ci_workspaces/WORKSPACE.sbsa +++ b/toolchains/ci_workspaces/WORKSPACE.sbsa @@ -49,50 +49,6 @@ new_local_repository( 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 = "8d9e829ce9478db4f35bdb7943308cf02e8a2f58cf9bb10f742462c1d57bf287", -# strip_prefix = "libtorch", -# urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.11.0%2Bcu113.zip"], -#) -# -#http_archive( -# name = "libtorch_pre_cxx11_abi", -# build_file = "@//third_party/libtorch:BUILD", -# sha256 = "90159ecce3ff451f3ef3f657493b6c7c96759c3b74bbd70c1695f2ea2f81e1ad", -# strip_prefix = "libtorch", -# urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-shared-with-deps-1.11.0%2Bcu113.zip"], -#) - -# Download these tarballs manually from the NVIDIA website -# Either place them in the distdir directory in third_party and use the --distdir flag -# or modify the urls to "file:////.tar.gz - -#http_archive( -# name = "cudnn", -# build_file = "@//third_party/cudnn/archive:BUILD", -# sha256 = "0e5d2df890b9967efa6619da421310d97323565a79f05a1a8cb9b7165baad0d7", -# strip_prefix = "cuda", -# urls = [ -# "https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.2.4/11.4_20210831/cudnn-11.4-linux-x64-v8.2.4.15.tgz", -# ], -#) -# -#http_archive( -# name = "tensorrt", -# build_file = "@//third_party/tensorrt/archive:BUILD", -# sha256 = "826180eaaecdf9a7e76116855b9f1f3400ea9b06e66b06a3f6a0747ba6f863ad", -# strip_prefix = "TensorRT-8.2.4.2", -# urls = [ -# "https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/8.2.4/tars/tensorrt-8.2.4.2.linux.x86_64-gnu.cuda-11.4.cudnn8.2.tar.gz", -# ], -#) - #################################################################################### # Locally installed dependencies (use in cases of custom dependencies or aarch64) #################################################################################### @@ -128,19 +84,6 @@ new_local_repository( build_file = "@//third_party/tensorrt/local:BUILD" ) -# ######################################################################### -# # Testing Dependencies (optional - comment out on aarch64) -# ######################################################################### -# pip_install( -# name = "torch_tensorrt_py_deps", -# requirements = "//py:requirements.txt", -# ) - -# pip_install( -# name = "py_test_deps", -# requirements = "//tests/py:requirements.txt", -# ) - pip_install( name = "pylinter_deps", requirements = "//tools/linter:requirements.txt", diff --git a/toolchains/ci_workspaces/WORKSPACE.x86_64 b/toolchains/ci_workspaces/WORKSPACE.x86_64 index 00f8efc5df..1caa1ce849 100644 --- a/toolchains/ci_workspaces/WORKSPACE.x86_64 +++ b/toolchains/ci_workspaces/WORKSPACE.x86_64 @@ -49,49 +49,6 @@ new_local_repository( 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 = "8d9e829ce9478db4f35bdb7943308cf02e8a2f58cf9bb10f742462c1d57bf287", -# strip_prefix = "libtorch", -# urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.11.0%2Bcu113.zip"], -#) -# -#http_archive( -# name = "libtorch_pre_cxx11_abi", -# build_file = "@//third_party/libtorch:BUILD", -# sha256 = "90159ecce3ff451f3ef3f657493b6c7c96759c3b74bbd70c1695f2ea2f81e1ad", -# strip_prefix = "libtorch", -# urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-shared-with-deps-1.11.0%2Bcu113.zip"], -#) - -# Download these tarballs manually from the NVIDIA website -# Either place them in the distdir directory in third_party and use the --distdir flag -# or modify the urls to "file:////.tar.gz - -#http_archive( -# name = "cudnn", -# build_file = "@//third_party/cudnn/archive:BUILD", -# sha256 = "0e5d2df890b9967efa6619da421310d97323565a79f05a1a8cb9b7165baad0d7", -# strip_prefix = "cuda", -# urls = [ -# "https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.2.4/11.4_20210831/cudnn-11.4-linux-x64-v8.2.4.15.tgz", -# ], -#) -# -#http_archive( -# name = "tensorrt", -# build_file = "@//third_party/tensorrt/archive:BUILD", -# sha256 = "826180eaaecdf9a7e76116855b9f1f3400ea9b06e66b06a3f6a0747ba6f863ad", -# strip_prefix = "TensorRT-8.2.4.2", -# urls = [ -# "https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/8.2.4/tars/tensorrt-8.2.4.2.linux.x86_64-gnu.cuda-11.4.cudnn8.2.tar.gz", -# ], -#) #################################################################################### # Locally installed dependencies (use in cases of custom dependencies or aarch64) @@ -128,19 +85,6 @@ new_local_repository( build_file = "@//third_party/tensorrt/local:BUILD" ) -# ######################################################################### -# # Testing Dependencies (optional - comment out on aarch64) -# ######################################################################### -# pip_install( -# name = "torch_tensorrt_py_deps", -# requirements = "//py:requirements.txt", -# ) - -# pip_install( -# name = "py_test_deps", -# requirements = "//tests/py:requirements.txt", -# ) - pip_install( name = "pylinter_deps", requirements = "//tools/linter:requirements.txt", diff --git a/toolchains/ci_workspaces/WORKSPACE.x86_64.release.rhel b/toolchains/ci_workspaces/WORKSPACE.x86_64.release.rhel new file mode 100644 index 0000000000..ba18c1d59d --- /dev/null +++ b/toolchains/ci_workspaces/WORKSPACE.x86_64.release.rhel @@ -0,0 +1,95 @@ +workspace(name = "Torch-TensorRT") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +http_archive( + name = "rules_python", + sha256 = "778197e26c5fbeb07ac2a2c5ae405b30f6cb7ad1f5510ea6fdac03bded96cc6f", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.2.0/rules_python-0.2.0.tar.gz", +) + +load("@rules_python//python:pip.bzl", "pip_install") + +http_archive( + name = "rules_pkg", + sha256 = "038f1caa773a7e35b3663865ffb003169c6a71dc995e39bf4815792f385d837d", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.4.0/rules_pkg-0.4.0.tar.gz", + "https://github.com/bazelbuild/rules_pkg/releases/download/0.4.0/rules_pkg-0.4.0.tar.gz", + ], +) + +load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") + +rules_pkg_dependencies() + +git_repository( + name = "googletest", + commit = "703bd9caab50b139428cea1aaff9974ebee5742e", + remote = "https://github.com/google/googletest", + shallow_since = "1570114335 -0400", +) + +# External dependency for torch_tensorrt if you already have precompiled binaries. +local_repository( + name = "torch_tensorrt", + path = "/opt/circleci/.pyenv/versions/3.9.4/lib/python3.9/site-packages/torch_tensorrt" +) + +# CUDA should be installed on the system locally +new_local_repository( + name = "cuda", + build_file = "@//third_party/cuda:BUILD", + path = "/usr/local/cuda-11.3", +) + +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 = "80f089939de20e68e3fcad4dfa72a26c8bf91b5e77b11042f671f39ebac35865", + strip_prefix = "libtorch", + urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.12.0%2Bcu113.zip"], +) + +http_archive( + name = "libtorch_pre_cxx11_abi", + build_file = "@//third_party/libtorch:BUILD", + sha256 = "8e35371403f7052d9e9b43bcff383980dbde4df028986dc1dab539953481d55f", + strip_prefix = "libtorch", + urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-shared-with-deps-1.12.0%2Bcu113.zip"], +) + +#################################################################################### +# Locally installed dependencies (use in cases of custom dependencies or aarch64) +#################################################################################### + +new_local_repository( + name = "cudnn", + path = "/usr/", + build_file = "@//third_party/cudnn/local:BUILD" +) + +new_local_repository( + name = "tensorrt", + path = "/usr/", + build_file = "@//third_party/tensorrt/local:BUILD" +) + +# ######################################################################### +# # Testing Dependencies (optional - comment out on aarch64) +# ######################################################################### + +pip_install( + name = "pylinter_deps", + requirements = "//tools/linter:requirements.txt", +) diff --git a/toolchains/ci_workspaces/WORKSPACE.x86_64.release.ubuntu b/toolchains/ci_workspaces/WORKSPACE.x86_64.release.ubuntu new file mode 100644 index 0000000000..d9c28bbda1 --- /dev/null +++ b/toolchains/ci_workspaces/WORKSPACE.x86_64.release.ubuntu @@ -0,0 +1,95 @@ +workspace(name = "Torch-TensorRT") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +http_archive( + name = "rules_python", + sha256 = "778197e26c5fbeb07ac2a2c5ae405b30f6cb7ad1f5510ea6fdac03bded96cc6f", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.2.0/rules_python-0.2.0.tar.gz", +) + +load("@rules_python//python:pip.bzl", "pip_install") + +http_archive( + name = "rules_pkg", + sha256 = "038f1caa773a7e35b3663865ffb003169c6a71dc995e39bf4815792f385d837d", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.4.0/rules_pkg-0.4.0.tar.gz", + "https://github.com/bazelbuild/rules_pkg/releases/download/0.4.0/rules_pkg-0.4.0.tar.gz", + ], +) + +load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") + +rules_pkg_dependencies() + +git_repository( + name = "googletest", + commit = "703bd9caab50b139428cea1aaff9974ebee5742e", + remote = "https://github.com/google/googletest", + shallow_since = "1570114335 -0400", +) + +# External dependency for torch_tensorrt if you already have precompiled binaries. +local_repository( + name = "torch_tensorrt", + path = "/opt/circleci/.pyenv/versions/3.9.4/lib/python3.9/site-packages/torch_tensorrt" +) + +# CUDA should be installed on the system locally +new_local_repository( + name = "cuda", + build_file = "@//third_party/cuda:BUILD", + path = "/usr/local/cuda", +) + +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 = "80f089939de20e68e3fcad4dfa72a26c8bf91b5e77b11042f671f39ebac35865", + strip_prefix = "libtorch", + urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.12.0%2Bcu113.zip"], +) + +http_archive( + name = "libtorch_pre_cxx11_abi", + build_file = "@//third_party/libtorch:BUILD", + sha256 = "8e35371403f7052d9e9b43bcff383980dbde4df028986dc1dab539953481d55f", + strip_prefix = "libtorch", + urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-shared-with-deps-1.12.0%2Bcu113.zip"], +) + +#################################################################################### +# Locally installed dependencies (use in cases of custom dependencies or aarch64) +#################################################################################### + +new_local_repository( + name = "cudnn", + path = "/usr/", + build_file = "@//third_party/cudnn/local:BUILD" +) + +new_local_repository( + name = "tensorrt", + path = "/usr/", + build_file = "@//third_party/tensorrt/local:BUILD" +) + +# ######################################################################### +# # Testing Dependencies (optional - comment out on aarch64) +# ######################################################################### + +pip_install( + name = "pylinter_deps", + requirements = "//tools/linter:requirements.txt", +) diff --git a/toolchains/distro/BUILD b/toolchains/distro/BUILD new file mode 100644 index 0000000000..1ed490c103 --- /dev/null +++ b/toolchains/distro/BUILD @@ -0,0 +1,7 @@ +package(default_visibility = ["//visibility:public"]) + +constraint_setting(name = "distro") +constraint_value( + name = "ci_rhel", + constraint_setting = ":distro" +) \ No newline at end of file