Skip to content

(//bazel): Native compilation support for Jetson AGX platform #113

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

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e05ed17
feat(//core/conversion/converters/impl): added support for linear1d a…
abhi-iyer Jun 9, 2020
d67cecf
feat(//core/conversion/converters/impl): added support for trilinear3…
abhi-iyer Jun 9, 2020
41108c9
test(/tests/core/converters/): added 3 tests for linear, bilinear, tr…
abhi-iyer Jun 9, 2020
8bc0531
feat(//core/conversion/converters/impl/plugins): template for interpo…
abhi-iyer Jun 11, 2020
a9ad817
feat(//core/conversion/converters/impl/plugins): interpolate plugin c…
abhi-iyer Jun 15, 2020
a072542
fix(): trying to resolve interpolate plugin problems
abhi-iyer Jun 16, 2020
a33d89b
fix(plugin): trying to fix bug in plugin
abhi-iyer Jun 17, 2020
0f37912
fix(BUILD): modified BUILD
abhi-iyer Jun 18, 2020
b26aca7
feat(//core/conversion/converters/impl):
abhi-iyer Jun 18, 2020
cebae40
test(tests/core/converters): Added test for plugins
abhi-iyer Jun 18, 2020
3e5c8c6
feat(//core/conversion/converters/impl/plugins): Created interpolate …
abhi-iyer Jun 18, 2020
ef4389a
feat(tests/util): added RunGraphEngineDynamic to handle dynamic input…
abhi-iyer Jun 18, 2020
2e853cc
feat(): added adaptive_avg_pool2d plugin, and added test for it
abhi-iyer Jun 18, 2020
ccf649f
feat(): support for adaptive_avg_pool2d plugin
abhi-iyer Jun 18, 2020
ba821d5
feat(): addressed some PR comments, refactored code
abhi-iyer Jun 18, 2020
029ea66
fix(): RunGraphEngineDynamic fixed to work with dynamically sized inp…
abhi-iyer Jun 19, 2020
e1bdb47
test(): added interpolate model for engine serialization testing
abhi-iyer Jun 19, 2020
2d9e44a
test(): Added engine serialization testing for interpolation model
abhi-iyer Jun 19, 2020
92343d5
fix(): fixed interpolate_plugin to handle dynamically sized inputs fo…
abhi-iyer Jun 19, 2020
5336cd2
fix(): fixed FP16 bug, fixed README, addressed some other PR comments
abhi-iyer Jun 19, 2020
5d497f9
docs: Remove known limitations section
narendasan Jun 19, 2020
05a6b65
fix(): need to fix gather converter
abhi-iyer Jun 25, 2020
c9f567a
test(aten::select.int): added test for aten::select.int
abhi-iyer Jun 25, 2020
0f25b86
feat(trt_util): from Naren, added unpadDims tool
abhi-iyer Jun 26, 2020
335a006
feat(//core/conversion/converters/impl): select converter, which adds…
abhi-iyer Jun 26, 2020
adc1d53
refactor(): removed unecessary imports from aten::select.int converter
abhi-iyer Jun 26, 2020
30909cc
test(aten::stack): Added test for aten::stack
abhi-iyer Jun 26, 2020
74fb809
feat(//core/conversion/converters/impl): added support for aten::stack
abhi-iyer Jun 26, 2020
f2d2fdc
tool(core/util/): added tool to unsqueeze dimensions at a specified i…
abhi-iyer Jun 26, 2020
d05d93d
test(aten::select): added test case for single call to select
abhi-iyer Jun 26, 2020
3ae414e
(//bazel): Added support for native compilation on NVIDIA Jetson AGX
Jun 24, 2020
3747489
Incorporate review comments
Jun 26, 2020
28fc9ff
Update build system
Jun 29, 2020
20415f0
fix(//third_party/cublas): cuBLAS source was incorrect, breaking out
narendasan Jul 1, 2020
d9ee10c
fix: Address issues with the build system picking up incorrect sources
narendasan Jul 1, 2020
c809eab
fix(//cpp/trtorchexec): typo extra comma
narendasan Jul 1, 2020
813289f
(//bazel): Incorporate review comments
Jul 6, 2020
98ec7f7
Merge branch 'master' into anuragd/aarch64-jetpack
andi4191 Jul 6, 2020
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
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ build:python --define=abi=pre_cxx11_abi

build:pre_cxx11_abi --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
build:pre_cxx11_abi --linkopt="-D_GLIBCXX_USE_CXX11_ABI=0"
build:pre_cxx11_abi --define=abi=pre_cxx11_abi
build:pre_cxx11_abi --define=abi=pre_cxx11_abi
25 changes: 12 additions & 13 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,56 @@ pkg_tar(
"//core/conversion:include",
"//core/conversion/conversionctx:include",
"//core/conversion/converters:include",
"//core/conversion/var:include",
"//core/conversion/tensorcontainer:include",
"//core/conversion/converters/impl/plugins:include",
"//core/conversion/evaluators:include",
"//core/conversion/tensorcontainer:include",
"//core/conversion/var:include",
"//core/conversion/converters/impl/plugins:include",
"//core/execution:include",
"//core/lowering:include",
"//core/lowering/passes:include",
"//core/util:include",
"//core/util/logging:include"
"//core/util/logging:include",
],
)

pkg_tar(
name = "include",
package_dir = "include/trtorch/",
srcs = [
"//cpp/api:api_headers",
],
package_dir = "include/trtorch/",
)

pkg_tar(
name = "lib",
package_dir = "lib/",
srcs = [
"//cpp/api/lib:libtrtorch.so",
],
mode = "0755",
package_dir = "lib/",
)


pkg_tar(
name = "bin",
package_dir = "bin/",
srcs = [
"//cpp/trtorchc:trtorchc",
"//cpp/trtorchc",
],
mode = "0755",
package_dir = "bin/",
)


pkg_tar(
name = "libtrtorch",
extension = "tar.gz",
package_dir = "trtorch",
srcs = [
"//:LICENSE"
"//:LICENSE",
],
extension = "tar.gz",
package_dir = "trtorch",
deps = [
":lib",
":bin",
":include",
":include_core",
":lib",
],
)
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ torch.jit.save(trt_ts_module, "trt_torchscript_module.ts")
| Platform | Support |
| -------- | ------- |
| Linux AMD64 / GPU | **Supported** |
| Linux aarch64 / GPU | **Planned/Possible with Native Compiation but untested** |
| Linux aarch64 / DLA | **Planned/Possible with Native Compilation but untested** |
| Linux aarch64 / GPU | **Native Compilation Supported on JetPack-4.4** |
| Linux aarch64 / DLA | **Native Compilation Supported on JetPack-4.4 but untested** |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try resnet 50 on DLA with trtorchc?

| Windows / GPU | - |
| Linux ppc64le / GPU | - |

> Note: Refer NVIDIA NGC container(https://ngc.nvidia.com/catalog/containers/nvidia:l4t-pytorch) for PyTorch libraries on JetPack.

### Dependencies

- Bazel 3.2.0
Expand Down Expand Up @@ -171,6 +173,11 @@ bazel build //:libtrtorch --compilation_mode opt
bazel build //:libtrtorch --compilation_mode=dbg
```

### Native compilation on NVIDIA Jetson AGX
``` shell
bazel build //:libtrtorch --cpu=aarch64 --distdir third_party/distdir/aarch64-linux-gnu
```

A tarball with the include files and library can then be found in bazel-bin

### Running TRTorch on a JIT Graph
Expand Down
101 changes: 72 additions & 29 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,30 @@ http_archive(
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
rules_pkg_dependencies()

git_repository(
name = "googletest",
remote = "https://github.com/google/googletest",
commit = "703bd9caab50b139428cea1aaff9974ebee5742e",
shallow_since = "1570114335 -0400"
)

# CUDA should be installed on the system locally
new_local_repository(
name = "cuda",
path = "/usr/local/cuda-10.2/targets/x86_64-linux/",
path = "/usr/local/cuda-10.2/",
build_file = "@//third_party/cuda:BUILD",
)

http_archive(
name = "libtorch_pre_cxx11_abi",
build_file = "@//third_party/libtorch:BUILD",
strip_prefix = "libtorch",
sha256 = "ea8de17c5f70015583f3a7a43c7a5cdf91a1d4bd19a6a7bc11f074ef6cd69e27",
urls = ["https://download.pytorch.org/libtorch/cu102/libtorch-shared-with-deps-1.5.0.zip"],
new_local_repository(
name = "cublas",
path = "/usr",
build_file = "@//third_party/cublas:BUILD",
)

#############################################################################################################
# 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",
Expand All @@ -48,23 +57,18 @@ http_archive(
sha256 = "0efdd4e709ab11088fa75f0501c19b0e294404231442bab1d1fb953924feb6b5"
)

pip3_import(
name = "trtorch_py_deps",
requirements = "//py:requirements.txt"
)

load("@trtorch_py_deps//:requirements.bzl", "pip_install")
pip_install()

pip3_import(
name = "py_test_deps",
requirements = "//tests/py:requirements.txt"
http_archive(
name = "libtorch_pre_cxx11_abi",
build_file = "@//third_party/libtorch:BUILD",
strip_prefix = "libtorch",
sha256 = "ea8de17c5f70015583f3a7a43c7a5cdf91a1d4bd19a6a7bc11f074ef6cd69e27",
urls = ["https://download.pytorch.org/libtorch/cu102/libtorch-shared-with-deps-1.5.0.zip"],
)

load("@py_test_deps//:requirements.bzl", "pip_install")
pip_install()
# 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:///<PATH TO TARBALL>/<TARBALL NAME>.tar.gz

# Downloaded distributions to use with --distdir
http_archive(
name = "cudnn",
urls = ["https://developer.nvidia.com/compute/machine-learning/cudnn/secure/7.6.5.32/Production/10.2_20191118/cudnn-10.2-linux-x64-v7.6.5.32.tgz"],
Expand All @@ -81,22 +85,61 @@ http_archive(
strip_prefix = "TensorRT-7.0.0.11"
)

## Locally installed dependencies
# new_local_repository(
####################################################################################
# Locally installed dependencies (use in cases of custom dependencies or aarch64)
####################################################################################

# NOTE: In the case you are using just the pre-cxx11-abi path or just the cxx11 abi path
# with your local libtorch, just point deps at the same path to satisfy bazel.

# NOTE: NVIDIA's aarch64 PyTorch (python) wheel file uses the CXX11 ABI unlike PyTorch's standard
# x86_64 python distribution. If using NVIDIA's version just point to the root of the package
# for both versions here and do not use --config=pre-cxx11-abi

#new_local_repository(
# name = "libtorch",
# path = "/usr/local/lib/python3.6/dist-packages/torch",
# # Use below for aarch64
# #path = "/home/nvidia/.local/lib/python3.6/site-packages/torch",
# build_file = "third_party/libtorch/BUILD"
#)

#new_local_repository(
# name = "libtorch_pre_cxx11_abi",
# path = "/usr/local/lib/python3.6/dist-packages/torch",
# # Use below for aarch64
# #path = "/home/nvidia/.local/lib/python3.6/site-packages/torch",
# build_file = "third_party/libtorch/BUILD"
#)

#new_local_repository(
# name = "cudnn",
# path = "/usr/",
# build_file = "@//third_party/cudnn/local:BUILD"
#)

# new_local_repository(
#new_local_repository(
# name = "tensorrt",
# path = "/usr/",
# build_file = "@//third_party/tensorrt/local:BUILD"
#)

git_repository(
name = "googletest",
remote = "https://github.com/google/googletest",
commit = "703bd9caab50b139428cea1aaff9974ebee5742e",
shallow_since = "1570114335 -0400"
#########################################################################
# Testing Dependencies (optional - comment out on aarch64)
#########################################################################

pip3_import(
name = "trtorch_py_deps",
requirements = "//py:requirements.txt"
)

load("@trtorch_py_deps//:requirements.bzl", "pip_install")
pip_install()

pip3_import(
name = "py_test_deps",
requirements = "//tests/py:requirements.txt"
)

load("@py_test_deps//:requirements.bzl", "pip_install")
pip_install()
19 changes: 9 additions & 10 deletions core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,34 @@ config_setting(
name = "use_pre_cxx11_abi",
values = {
"define": "abi=pre_cxx11_abi",
}
},
)

cc_library(
name = "core",
hdrs = [
"compiler.h",
],
srcs = [
"compiler.cpp",
],
hdrs = [
"compiler.h",
],
deps = [
"//core/conversion",
"//core/execution",
"//core/lowering",
"//core/util/logging",
"@tensorrt//:nvinfer"
"@tensorrt//:nvinfer",
] + select({
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
}),
alwayslink=True,
alwayslink = True,
)


load("@rules_pkg//:pkg.bzl", "pkg_tar")

pkg_tar(
name = "include",
package_dir = "core/",
srcs = ["compiler.h"],
package_dir = "core/",
)
20 changes: 10 additions & 10 deletions core/conversion/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ config_setting(
name = "use_pre_cxx11_abi",
values = {
"define": "abi=pre_cxx11_abi",
}
},
)

cc_library(
name = "conversion",
hdrs = [
"conversion.h",
],
srcs = [
"InterfaceTypes.cpp",
"conversion.cpp",
"conversion_blacklist.cpp",
"InterfaceTypes.cpp"
],
hdrs = [
"conversion.h",
],
deps = [
"@tensorrt//:nvinfer",
"//core/conversion/var",
"//core/conversion/conversionctx",
"//core/conversion/converters",
"//core/conversion/evaluators",
"//core/util:prelude"
"//core/util:prelude",
"@tensorrt//:nvinfer",
] + select({
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
}),
)

load("@rules_pkg//:pkg.bzl", "pkg_tar")

pkg_tar(
name = "include",
package_dir = "core/conversion/",
srcs = ["conversion.h"],
package_dir = "core/conversion/",
)
16 changes: 8 additions & 8 deletions core/conversion/conversionctx/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ config_setting(
name = "use_pre_cxx11_abi",
values = {
"define": "abi=pre_cxx11_abi",
}
},
)

cc_library(
name = "conversionctx",
hdrs = [
"ConversionCtx.h",
],
srcs = [
"ConversionCtx.cpp",
],
hdrs = [
"ConversionCtx.h",
],
deps = [
"@tensorrt//:nvinfer",
"//core/util:prelude",
"@tensorrt//:nvinfer",
] + select({
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
}),
)

load("@rules_pkg//:pkg.bzl", "pkg_tar")

pkg_tar(
name = "include",
package_dir = "core/conversion/conversionctx/",
srcs = ["ConversionCtx.h"],
package_dir = "core/conversion/conversionctx/",
)
Loading