|
| 1 | +module( |
| 2 | + name = "torch_tensorrt", |
| 3 | + repo_name = "org_pytorch_tensorrt", |
| 4 | + version = "${BUILD_VERSION}" |
| 5 | +) |
| 6 | + |
| 7 | +bazel_dep(name = "googletest", version = "1.14.0") |
| 8 | +bazel_dep(name = "platforms", version = "0.0.10") |
| 9 | +bazel_dep(name = "rules_cc", version = "0.0.9") |
| 10 | +bazel_dep(name = "rules_python", version = "0.34.0") |
| 11 | + |
| 12 | +python = use_extension("@rules_python//python/extensions:python.bzl", "python") |
| 13 | +python.toolchain( |
| 14 | + ignore_root_user_error = True, |
| 15 | + python_version = "3.11", |
| 16 | +) |
| 17 | + |
| 18 | +bazel_dep(name = "rules_pkg", version = "1.0.1") |
| 19 | +git_override( |
| 20 | + module_name = "rules_pkg", |
| 21 | + commit = "17c57f4", |
| 22 | + remote = "https://github.com/narendasan/rules_pkg", |
| 23 | +) |
| 24 | + |
| 25 | +local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository") |
| 26 | + |
| 27 | +# External dependency for torch_tensorrt if you already have precompiled binaries. |
| 28 | +local_repository( |
| 29 | + name = "torch_tensorrt", |
| 30 | + path = "/opt/conda/lib/python3.8/site-packages/torch_tensorrt", |
| 31 | +) |
| 32 | + |
| 33 | + |
| 34 | +new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository") |
| 35 | + |
| 36 | +# CUDA should be installed on the system locally |
| 37 | +new_local_repository( |
| 38 | + name = "cuda", |
| 39 | + build_file = "@//third_party/cuda:BUILD", |
| 40 | + path = "${CUDA_HOME}", |
| 41 | +) |
| 42 | + |
| 43 | +new_local_repository( |
| 44 | + name = "cuda_win", |
| 45 | + build_file = "@//third_party/cuda:BUILD", |
| 46 | + path = "${CUDA_HOME}", |
| 47 | +) |
| 48 | + |
| 49 | + |
| 50 | +http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| 51 | + |
| 52 | +############################################################################################################# |
| 53 | +# Tarballs and fetched dependencies (default - use in cases when building from precompiled bin and tarballs) |
| 54 | +############################################################################################################# |
| 55 | + |
| 56 | +http_archive( |
| 57 | + name = "libtorch", |
| 58 | + build_file = "@//third_party/libtorch:BUILD", |
| 59 | + strip_prefix = "libtorch", |
| 60 | + urls = ["https://download.pytorch.org/libtorch/${CHANNEL}/${CU_VERSION}/libtorch-cxx11-abi-shared-with-deps-latest.zip"], |
| 61 | +) |
| 62 | + |
| 63 | +# Download these tarballs manually from the NVIDIA website |
| 64 | +# Either place them in the distdir directory in third_party and use the --distdir flag |
| 65 | +# or modify the urls to "file:///<PATH TO TARBALL>/<TARBALL NAME>.tar.gz |
| 66 | + |
| 67 | +http_archive( |
| 68 | + name = "tensorrt", |
| 69 | + build_file = "@//third_party/tensorrt/archive:BUILD", |
| 70 | + sha256 = "${TENSORRT_SHA256}", |
| 71 | + strip_prefix = "${TENSORRT_STRIP_PREFIX}", |
| 72 | + urls = [ |
| 73 | + "${TENSORRT_URLS}", |
| 74 | + ], |
| 75 | +) |
| 76 | + |
| 77 | +http_archive( |
| 78 | + name = "tensorrt_win", |
| 79 | + build_file = "@//third_party/tensorrt/archive:BUILD", |
| 80 | + sha256 = "${TENSORRT_SHA256}", |
| 81 | + strip_prefix = "${TENSORRT_STRIP_PREFIX}", |
| 82 | + urls = [ |
| 83 | + "${TENSORRT_URLS}", |
| 84 | + ], |
| 85 | +) |
| 86 | + |
| 87 | + |
| 88 | +#################################################################################### |
| 89 | +# Locally installed dependencies (use in cases of custom dependencies or aarch64) |
| 90 | +#################################################################################### |
| 91 | + |
| 92 | +# NOTE: In the case you are using just the pre-cxx11-abi path or just the cxx11 abi path |
| 93 | +# with your local libtorch, just point deps at the same path to satisfy bazel. |
| 94 | + |
| 95 | +# NOTE: NVIDIA's aarch64 PyTorch (python) wheel file uses the CXX11 ABI unlike PyTorch's standard |
| 96 | +# x86_64 python distribution. If using NVIDIA's version just point to the root of the package |
| 97 | +# for both versions here and do not use --config=pre-cxx11-abi |
| 98 | + |
| 99 | +new_local_repository( |
| 100 | + name = "libtorch_win", |
| 101 | + path = "${TORCH_INSTALL_PATH}", |
| 102 | + build_file = "third_party/libtorch/BUILD" |
| 103 | +) |
| 104 | + |
| 105 | +new_local_repository( |
| 106 | + name = "libtorch_pre_cxx11_abi", |
| 107 | + path = "${TORCH_INSTALL_PATH}", |
| 108 | + build_file = "third_party/libtorch/BUILD" |
| 109 | +) |
| 110 | + |
| 111 | +#new_local_repository( |
| 112 | +# name = "tensorrt", |
| 113 | +# path = "/usr/", |
| 114 | +# build_file = "@//third_party/tensorrt/local:BUILD" |
| 115 | +#) |
0 commit comments