Skip to content

Commit 5fadfd4

Browse files
authored
Merge branch 'master' into squashed_collections
2 parents f519935 + 84ffb67 commit 5fadfd4

File tree

80 files changed

+2658
-213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2658
-213
lines changed

.circleci/config.yml

Lines changed: 239 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,38 @@ commands:
155155
platform:
156156
type: string
157157
default: "x86_64"
158+
release:
159+
type: boolean
160+
default: false
158161
steps:
159162
- run:
160-
name: Build torch-tensorrt python release
163+
name: Build setup
161164
command: |
162-
mv toolchains/ci_workspaces/WORKSPACE.<< parameters.platform >> WORKSPACE
163-
cd py
165+
mv ~/project/toolchains/ci_workspaces/WORKSPACE.<< parameters.platform >> ~/project/WORKSPACE
164166
python3 -m pip install wheel setuptools
165167
python3 -m pip install pybind11==2.6.2
166-
python3 setup.py bdist_wheel --use-cxx11-abi
167-
python3 setup.py install --use-cxx11-abi
168-
mkdir -p /tmp/dist/builds
169-
cp dist/* /tmp/dist/builds
168+
- when:
169+
condition: << parameters.release >>
170+
steps:
171+
- run:
172+
name: Build torch-tensorrt python release package
173+
command: |
174+
cd ~/project/py
175+
python3 setup.py bdist_wheel --use-cxx11-abi --release
176+
python3 setup.py install --use-cxx11-abi --release
177+
mkdir -p /tmp/dist/builds
178+
cp dist/* /tmp/dist/builds
179+
- unless:
180+
condition: << parameters.release >>
181+
steps:
182+
- run:
183+
name: Build torch-tensorrt python package
184+
command: |
185+
cd ~/project/py
186+
python3 setup.py bdist_wheel --use-cxx11-abi
187+
python3 setup.py install --use-cxx11-abi
188+
mkdir -p /tmp/dist/builds
189+
cp dist/* /tmp/dist/builds
170190
171191
build-py-fx-only:
172192
description: "Build the torch-tensorrt python release with only the fx backend"
@@ -579,6 +599,150 @@ jobs:
579599
- dump-test-env
580600
- test-fx
581601

602+
package-x86_64:
603+
parameters:
604+
enabled:
605+
type: boolean
606+
default: false
607+
torch-build:
608+
type: string
609+
torch-build-index:
610+
type: string
611+
machine:
612+
image: ubuntu-2004-cuda-11.4:202110-01
613+
resource_class: xlarge
614+
steps:
615+
- when:
616+
condition: << parameters.enabled >>
617+
steps:
618+
- checkout
619+
- run:
620+
name: "Build packaging container"
621+
command: |
622+
cd ~/project/py/
623+
docker build -t torch_tensorrt_release_env --build-arg trt_version=<< pipeline.parameters.trt-release-version-short >> -f ci/Dockerfile.ci .
624+
- run:
625+
name: Build Python packages and pre-cxx11-abi tarball
626+
command: |
627+
cd ~/project/py/
628+
cp ~/project/toolchains/ci_workspaces/WORKSPACE.x86_64.release.rhel ~/project/WORKSPACE
629+
docker run -it --rm -v ~/project:/workspace/project torch_tensorrt_release_env /bin/bash /workspace/project/py/ci/build_whl.sh
630+
- create-env:
631+
os: "ubuntu2004"
632+
platform: "x86_64"
633+
cudnn-version: << pipeline.parameters.cudnn-release-version >>
634+
trt-version-short: << pipeline.parameters.trt-release-version-short >>
635+
bazel-version: "5.1.1"
636+
bazel-platform: "x86_64"
637+
- run:
638+
name: Build cxx11-abi tarball
639+
command: |
640+
set -e
641+
cd ~/project/
642+
cp ~/project/toolchains/ci_workspaces/WORKSPACE.x86_64.release.ubuntu ~/project/WORKSPACE
643+
bazel build //:libtorchtrt -c opt --noshow_progress
644+
sudo chown -R $(whoami) ~/project/py
645+
CUDA_VERSION=$(cd ~/project/py/torch_tensorrt && python3 -c "from _version import __cuda_version__;print(__cuda_version__)")
646+
TORCHTRT_VERSION=$(cd ~/project/py/torch_tensorrt && python3 -c "from _version import __version__;print(__version__)")
647+
TRT_VERSION=$(cd ~/project/py/torch_tensorrt && python3 -c "from _version import __tensorrt_version__;print(__tensorrt_version__)")
648+
CUDNN_VERSION=$(cd ~/project/py/torch_tensorrt && python3 -c "from _version import __cudnn_version__;print(__cudnn_version__)")
649+
pip3 install -r ~/project/py/requirements.txt
650+
TORCH_VERSION=$(python3 -c "from torch import __version__;print(__version__.split('+')[0])")
651+
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
652+
- run:
653+
name: Collect packages
654+
command: |
655+
mkdir -p /tmp/dist/release
656+
cp -r ~/project/py/dist/* /tmp/dist/release
657+
- store_artifacts:
658+
path: /tmp/dist/release
659+
destination: x86_64-release-pkgs
660+
- unless:
661+
condition: << parameters.enabled >>
662+
steps:
663+
- run:
664+
name: Skipped packaging
665+
command: echo -e "Packaging stage not enabled"
666+
667+
package-jetson:
668+
parameters:
669+
enabled:
670+
type: boolean
671+
default: true
672+
torch-build:
673+
type: string
674+
jetpack-version:
675+
type: string
676+
cxx11-abi:
677+
type: boolean
678+
default: true
679+
python-version:
680+
type: string
681+
default: 3.8.10
682+
machine:
683+
image: ubuntu-2004:202201-02
684+
resource_class: arm.xlarge
685+
steps:
686+
- checkout
687+
#- run:
688+
# name: Upgrade base
689+
# command: |
690+
# sudo apt clean
691+
# sudo apt update
692+
# sudo apt upgrade
693+
# sudo apt install software-properties-common
694+
- install-cuda:
695+
os: "ubuntu2004"
696+
platform: "sbsa"
697+
cuda-pkg-name: "cuda-toolkit-11-4"
698+
- run:
699+
name: Install openblas
700+
command: sudo apt install libopenblas-dev
701+
- create-env:
702+
os: "ubuntu2004"
703+
platform: "sbsa"
704+
cudnn-version: << pipeline.parameters.cudnn-jetson-version >>
705+
trt-version-short: << pipeline.parameters.trt-jetson-version-short >>
706+
bazel-version: "5.1.1"
707+
bazel-platform: "arm64"
708+
- run:
709+
name: Set python version
710+
command: |
711+
pyenv install << parameters.python-version >>
712+
pyenv global << parameters.python-version >>
713+
- run:
714+
name: Install NGC Torch
715+
environment:
716+
TORCH_INSTALL: https://developer.download.nvidia.com/compute/redist/jp/v<< parameters.jetpack-version >>/pytorch/<< parameters.torch-build >>
717+
command: |
718+
set -e
719+
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
720+
- build-py-cxx11-abi:
721+
platform: "sbsa"
722+
release: true
723+
- run:
724+
name: Build cxx11-abi tarball
725+
command: |
726+
set -e
727+
cd ~/project/py/
728+
bazel build //:libtorchtrt -c opt --noshow_progress
729+
CUDA_VERSION=$(cd torch_tensorrt && python3 -c "from _version import __cuda_version__;print(__cuda_version__)")
730+
TORCHTRT_VERSION=$(cd torch_tensorrt && python3 -c "from _version import __version__;print(__version__)")
731+
TRT_VERSION=$(cd torch_tensorrt && python3 -c "from _version import __tensorrt_version__;print(__tensorrt_version__)")
732+
CUDNN_VERSION=$(cd torch_tensorrt && python3 -c "from _version import __cudnn_version__;print(__cudnn_version__)")
733+
pip3 install -r ~/project/py/requirements.txt
734+
TORCH_VERSION=$(python3 -c "from torch import __version__;print(__version__.split('+')[0])")
735+
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
736+
- run:
737+
name: Move to release dir
738+
command: |
739+
mkdir -p /tmp/dist/jetson
740+
cp -r ~/project/py/dist/* /tmp/dist/jetson
741+
- store_artifacts:
742+
path: /tmp/dist/jetson
743+
destination: aarch64-release-pkgs
744+
745+
582746
parameters:
583747
# Nightly platform config
584748
torch-nightly-build:
@@ -631,6 +795,10 @@ parameters:
631795
type: string
632796
default: "8.4.1.5"
633797

798+
enable-packaging:
799+
type: boolean
800+
default: false
801+
634802
# Invoke jobs via workflows
635803
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
636804
workflows:
@@ -642,14 +810,14 @@ workflows:
642810
branches:
643811
only:
644812
- master
813+
- release/**/*
645814
jobs:
646815
- build-aarch64-pyt-jetson:
647816
torch-build: << pipeline.parameters.torch-jetson-build >>
648817
jetpack-version: << pipeline.parameters.jetpack-version >>
649818
python-version: 3.8.10
650819

651820

652-
653821
- build-x86_64-pyt-release:
654822
torch-build: << pipeline.parameters.torch-release-build >>
655823
torch-build-index: << pipeline.parameters.torch-release-build-index >>
@@ -684,8 +852,6 @@ workflows:
684852
- build-x86_64-pyt-release
685853

686854

687-
688-
689855
- build-x86_64-pyt-nightly:
690856
torch-build: << pipeline.parameters.torch-nightly-build >>
691857
torch-build-index: << pipeline.parameters.torch-nightly-build-index >>
@@ -719,13 +885,74 @@ workflows:
719885
requires:
720886
- build-x86_64-pyt-nightly
721887

722-
on-push:
888+
release:
889+
when: << pipeline.parameters.enable-packaging >>
723890
jobs:
724891
- build-aarch64-pyt-jetson:
725892
torch-build: << pipeline.parameters.torch-jetson-build >>
726893
jetpack-version: << pipeline.parameters.jetpack-version >>
727894
python-version: 3.8.10
728895

896+
- build-x86_64-pyt-release:
897+
torch-build: << pipeline.parameters.torch-release-build >>
898+
torch-build-index: << pipeline.parameters.torch-release-build-index >>
899+
900+
901+
- test-core-cpp-x86_64:
902+
name: test-core-cpp-x86_64-pyt-release
903+
channel: "release"
904+
torch-build: << pipeline.parameters.torch-release-build >>
905+
torch-build-index: << pipeline.parameters.torch-release-build-index >>
906+
trt-version-short: << pipeline.parameters.trt-release-version-short >>
907+
trt-version-long: << pipeline.parameters.trt-release-version-long >>
908+
cudnn-version: << pipeline.parameters.cudnn-release-version >>
909+
requires:
910+
- build-x86_64-pyt-release
911+
912+
- test-py-ts-x86_64:
913+
name: test-py-ts-x86_64-pyt-release
914+
channel: "release"
915+
torch-build: << pipeline.parameters.torch-release-build >>
916+
torch-build-index: << pipeline.parameters.torch-release-build-index >>
917+
trt-version-long: << pipeline.parameters.trt-release-version-long >>
918+
requires:
919+
- build-x86_64-pyt-release
920+
921+
- test-py-fx-x86_64:
922+
name: test-py-fx-x86_64-pyt-release
923+
channel: "release"
924+
torch-build: << pipeline.parameters.torch-release-build >>
925+
torch-build-index: << pipeline.parameters.torch-release-build-index >>
926+
trt-version-long: << pipeline.parameters.trt-release-version-long >>
927+
requires:
928+
- build-x86_64-pyt-release
929+
930+
931+
- package-x86_64:
932+
name: package-release-x86_64
933+
enabled: << pipeline.parameters.enable-packaging >>
934+
torch-build: << pipeline.parameters.torch-release-build >>
935+
torch-build-index: << pipeline.parameters.torch-release-build-index >>
936+
requires:
937+
- test-core-cpp-x86_64-pyt-release
938+
- test-py-ts-x86_64-pyt-release
939+
- test-py-fx-x86_64-pyt-release
940+
941+
- package-jetson:
942+
name: package-release-aarch64-jetson
943+
enabled: << pipeline.parameters.enable-packaging >>
944+
torch-build: << pipeline.parameters.torch-jetson-build >>
945+
jetpack-version: << pipeline.parameters.jetpack-version >>
946+
python-version: 3.8.10
947+
requires:
948+
- build-aarch64-pyt-jetson
949+
950+
on-push:
951+
jobs:
952+
- build-aarch64-pyt-jetson:
953+
torch-build: << pipeline.parameters.torch-jetson-build >>
954+
jetpack-version: << pipeline.parameters.jetpack-version >>
955+
python-version: 3.8.10
729956

730957

731958
- build-x86_64-pyt-release:
@@ -762,7 +989,6 @@ workflows:
762989
- build-x86_64-pyt-release
763990

764991

765-
766992
- build-x86_64-pyt-nightly:
767993
torch-build: << pipeline.parameters.torch-nightly-build >>
768994
torch-build-index: << pipeline.parameters.torch-nightly-build-index >>
@@ -794,5 +1020,4 @@ workflows:
7941020
torch-build-index: << pipeline.parameters.torch-nightly-build-index >>
7951021
trt-version-long: << pipeline.parameters.trt-nightly-version-long >>
7961022
requires:
797-
- build-x86_64-pyt-nightly
798-
1023+
- build-x86_64-pyt-nightly

CMakeLists.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
cmake_minimum_required(VERSION 3.17)
3+
project(Torch-TensorRT LANGUAGES CXX)
4+
5+
# use c++17
6+
set(CMAKE_CXX_STANDARD 17)
7+
8+
# Build the libraries with -fPIC
9+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
10+
11+
if (DEFINED CMAKE_MODULE_PATH)
12+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} CACHE PATH "Path to the folder containing finders")
13+
endif()
14+
15+
include(cmake/build_options.cmake)
16+
include(cmake/paths.cmake)
17+
include(cmake/dependencies.cmake)
18+
if(MSVC)
19+
add_compile_options(/wd4624 /wd4067 /permissive-)
20+
# When using Ninja generator, suppress the warning D9025
21+
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
22+
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
23+
endif()
24+
# -----------------------------------------
25+
# compilation
26+
# -----------------------------------------
27+
add_subdirectory(core)
28+
add_subdirectory(cpp)
29+
30+
include(CMakePackageConfigHelpers)
31+
32+
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
33+
"${CMAKE_CURRENT_BINARY_DIR}/torchtrtConfig.cmake"
34+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/torchtrt
35+
)
36+
37+
install(FILES
38+
"${CMAKE_CURRENT_BINARY_DIR}/torchtrtConfig.cmake"
39+
# "${CMAKE_CURRENT_BINARY_DIR}/torchtrtConfigVersion.cmake"
40+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/torchtrt
41+
)

Config.cmake.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@PACKAGE_INIT@
2+
3+
include(CMakeFindDependencyMacro)
4+
5+
find_dependency(Torch)
6+
find_package(TensorRT QUIET)
7+
if (NOT TensorRT_FOUND)
8+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Modules")
9+
find_dependency(TensorRT)
10+
endif()
11+
include("${CMAKE_CURRENT_LIST_DIR}/torchtrtTargets.cmake")
12+
13+
check_required_components(MathFunctions)

0 commit comments

Comments
 (0)