Skip to content

Commit 7ea3638

Browse files
Add jetson build on CI (#3524)
Co-authored-by: Naren Dasan <[email protected]>
1 parent 413e4ec commit 7ea3638

File tree

42 files changed

+403
-230
lines changed

Some content is hidden

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

42 files changed

+403
-230
lines changed

.github/scripts/filter-matrix.py

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
# currently we don't support python 3.13t due to tensorrt does not support 3.13t
1010
disabled_python_versions: List[str] = ["3.13t"]
1111

12+
# jetpack 6.2 only officially supports python 3.10 and cu126
13+
jetpack_python_versions: List[str] = ["3.10"]
14+
jetpack_cuda_versions: List[str] = ["cu126"]
15+
16+
jetpack_container_image: str = "nvcr.io/nvidia/l4t-jetpack:r36.4.0"
17+
sbsa_container_image: str = "quay.io/pypa/manylinux_2_34_aarch64"
18+
1219

1320
def main(args: list[str]) -> None:
1421
parser = argparse.ArgumentParser()
@@ -19,8 +26,23 @@ def main(args: list[str]) -> None:
1926
default="",
2027
)
2128

22-
options = parser.parse_args(args)
29+
parser.add_argument(
30+
"--jetpack",
31+
help="is jetpack",
32+
type=str,
33+
choices=["true", "false"],
34+
default="false",
35+
)
2336

37+
parser.add_argument(
38+
"--limit-pr-builds",
39+
help="If it is a PR build",
40+
type=str,
41+
choices=["true", "false"],
42+
default=os.getenv("LIMIT_PR_BUILDS", "false"),
43+
)
44+
45+
options = parser.parse_args(args)
2446
if options.matrix == "":
2547
raise Exception("--matrix needs to be provided")
2648

@@ -30,14 +52,29 @@ def main(args: list[str]) -> None:
3052
for item in includes:
3153
if item["python_version"] in disabled_python_versions:
3254
continue
33-
if item["gpu_arch_type"] == "cuda-aarch64":
34-
# pytorch image:pytorch/manylinuxaarch64-builder:cuda12.8 comes with glibc2.28
35-
# however, TensorRT requires glibc2.31 on aarch64 platform
36-
# TODO: in future, if pytorch supports aarch64 with glibc2.31, we should switch to use the pytorch image
37-
item["container_image"] = "quay.io/pypa/manylinux_2_34_aarch64"
38-
filtered_includes.append(item)
55+
if options.jetpack == "true":
56+
if options.limit_pr_builds == "true":
57+
# limit pr build, matrix passed in from test-infra is cu128, python 3.9, change to cu126, python 3.10
58+
item["desired_cuda"] = "cu126"
59+
item["python_version"] = "3.10"
60+
item["container_image"] = jetpack_container_image
61+
filtered_includes.append(item)
62+
else:
63+
if (
64+
item["python_version"] in jetpack_python_versions
65+
and item["desired_cuda"] in jetpack_cuda_versions
66+
):
67+
item["container_image"] = jetpack_container_image
68+
filtered_includes.append(item)
3969
else:
40-
filtered_includes.append(item)
70+
if item["gpu_arch_type"] == "cuda-aarch64":
71+
# pytorch image:pytorch/manylinuxaarch64-builder:cuda12.8 comes with glibc2.28
72+
# however, TensorRT requires glibc2.31 on aarch64 platform
73+
# TODO: in future, if pytorch supports aarch64 with glibc2.31, we should switch to use the pytorch image
74+
item["container_image"] = sbsa_container_image
75+
filtered_includes.append(item)
76+
else:
77+
filtered_includes.append(item)
4178
filtered_matrix_dict = {}
4279
filtered_matrix_dict["include"] = filtered_includes
4380
print(json.dumps(filtered_matrix_dict))
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build and test Linux aarch64 wheels for Jetpack
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- nightly
9+
- release/*
10+
tags:
11+
# NOTE: Binary build pipelines should only get triggered on release candidate builds
12+
# Release candidate tags look like: v1.11.0-rc1
13+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
14+
workflow_dispatch:
15+
16+
jobs:
17+
generate-matrix:
18+
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
19+
with:
20+
package-type: wheel
21+
os: linux-aarch64
22+
test-infra-repository: pytorch/test-infra
23+
test-infra-ref: main
24+
with-rocm: false
25+
with-cpu: false
26+
27+
filter-matrix:
28+
needs: [generate-matrix]
29+
outputs:
30+
matrix: ${{ steps.filter.outputs.matrix }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/setup-python@v5
34+
with:
35+
python-version: "3.11"
36+
- uses: actions/checkout@v4
37+
with:
38+
repository: pytorch/tensorrt
39+
- name: Filter matrix
40+
id: filter
41+
env:
42+
LIMIT_PR_BUILDS: ${{ github.event_name == 'pull_request' && !contains( github.event.pull_request.labels.*.name, 'ciflow/binaries/all') }}
43+
run: |
44+
set -eou pipefail
45+
echo "LIMIT_PR_BUILDS=${LIMIT_PR_BUILDS}"
46+
MATRIX_BLOB=${{ toJSON(needs.generate-matrix.outputs.matrix) }}
47+
MATRIX_BLOB="$(python3 .github/scripts/filter-matrix.py --matrix "${MATRIX_BLOB}" --jetpack true)"
48+
echo "${MATRIX_BLOB}"
49+
echo "matrix=${MATRIX_BLOB}" >> "${GITHUB_OUTPUT}"
50+
51+
build:
52+
needs: filter-matrix
53+
permissions:
54+
id-token: write
55+
contents: read
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
include:
60+
- repository: pytorch/tensorrt
61+
pre-script: packaging/pre_build_script.sh
62+
env-var-script: packaging/env_vars.txt
63+
post-script: packaging/post_build_script.sh
64+
smoke-test-script: packaging/smoke_test_script.sh
65+
package-name: torch_tensorrt
66+
name: Build torch-tensorrt whl package
67+
uses: ./.github/workflows/build_wheels_linux_aarch64.yml
68+
with:
69+
repository: ${{ matrix.repository }}
70+
ref: ""
71+
test-infra-repository: pytorch/test-infra
72+
test-infra-ref: main
73+
build-matrix: ${{ needs.filter-matrix.outputs.matrix }}
74+
pre-script: ${{ matrix.pre-script }}
75+
env-var-script: ${{ matrix.env-var-script }}
76+
post-script: ${{ matrix.post-script }}
77+
package-name: ${{ matrix.package-name }}
78+
smoke-test-script: ${{ matrix.smoke-test-script }}
79+
trigger-event: ${{ github.event_name }}
80+
architecture: "aarch64"
81+
is-jetpack: true
82+
83+
84+
concurrency:
85+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }}
86+
cancel-in-progress: true

.github/workflows/build-test-linux-aarch64.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
filter-matrix:
2828
needs: [generate-matrix]
2929
outputs:
30-
matrix: ${{ steps.generate.outputs.matrix }}
30+
matrix: ${{ steps.filter.outputs.matrix }}
3131
runs-on: ubuntu-latest
3232
steps:
3333
- uses: actions/setup-python@v5
@@ -36,8 +36,10 @@ jobs:
3636
- uses: actions/checkout@v4
3737
with:
3838
repository: pytorch/tensorrt
39-
- name: Generate matrix
40-
id: generate
39+
- name: Filter matrix
40+
id: filter
41+
env:
42+
LIMIT_PR_BUILDS: ${{ github.event_name == 'pull_request' && !contains( github.event.pull_request.labels.*.name, 'ciflow/binaries/all') }}
4143
run: |
4244
set -eou pipefail
4345
MATRIX_BLOB=${{ toJSON(needs.generate-matrix.outputs.matrix) }}

.github/workflows/build-test-linux-x86_64.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and test Linux wheels
1+
name: Build and test Linux x86_64 wheels
22

33
on:
44
pull_request:

.github/workflows/build_wheels_linux_aarch64.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ on:
8888
required: false
8989
default: "python -m build --wheel"
9090
type: string
91+
is-jetpack:
92+
description: Set to true if the build is for jetpack
93+
required: false
94+
default: false
95+
type: boolean
9196
pip-install-torch-extra-args:
9297
# NOTE: Why does this exist?
9398
# Well setuptools / python packaging doesn't actually allow you to specify dependencies
@@ -128,7 +133,7 @@ jobs:
128133
UPLOAD_TO_BASE_BUCKET: ${{ matrix.upload_to_base_bucket }}
129134
ARCH: ${{ inputs.architecture }}
130135
BUILD_TARGET: ${{ inputs.build-target }}
131-
name: build-${{ matrix.build_name }}
136+
name: build-wheel-${{ matrix.python_version }}-${{ matrix.desired_cuda }}-${{ matrix.gpu_arch_type }}
132137
runs-on: ${{ matrix.validation_runner }}
133138
environment: ${{(inputs.trigger-event == 'schedule' || (inputs.trigger-event == 'push' && (startsWith(github.event.ref, 'refs/heads/nightly') || startsWith(github.event.ref, 'refs/tags/v')))) && 'pytorchbot-env' || ''}}
134139
container:
@@ -170,6 +175,11 @@ jobs:
170175
# when using Python version, less than the conda latest
171176
###############################################################################
172177
echo 'Installing conda-forge'
178+
if [[ ${{ inputs.is-jetpack }} == true ]]; then
179+
# jetpack base image is ubuntu 22.04, does not have curl installed
180+
apt-get update
181+
apt-get install -y curl git
182+
fi
173183
curl -L -o /mambaforge.sh https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh
174184
chmod +x /mambaforge.sh
175185
/mambaforge.sh -b -p /opt/conda
@@ -195,12 +205,11 @@ jobs:
195205
python-version: ${{ env.PYTHON_VERSION }}
196206
cuda-version: ${{ env.CU_VERSION }}
197207
arch: ${{ env.ARCH }}
198-
199208
- name: Combine Env Var and Build Env Files
200209
if: ${{ inputs.env-var-script != '' }}
201210
working-directory: ${{ inputs.repository }}
202211
run: |
203-
set -euxo pipefail
212+
set -x
204213
cat "${{ inputs.env-var-script }}" >> "${BUILD_ENV_FILE}"
205214
- name: Add XPU Env Vars in Build Env File
206215
if: ${{ matrix.gpu_arch_type == 'xpu' }}
@@ -211,6 +220,7 @@ jobs:
211220
echo "source /opt/intel/oneapi/pti/latest/env/vars.sh"
212221
} >> "${BUILD_ENV_FILE}"
213222
- name: Install torch dependency
223+
if: ${{ inputs.is-jetpack == false }}
214224
run: |
215225
set -euxo pipefail
216226
# shellcheck disable=SC1090
@@ -241,12 +251,17 @@ jobs:
241251
working-directory: ${{ inputs.repository }}
242252
shell: bash -l {0}
243253
run: |
244-
set -euxo pipefail
254+
#set -euxo pipefail
255+
set -x
245256
source "${BUILD_ENV_FILE}"
246257
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
247258
${CONDA_RUN} python setup.py clean
248259
echo "Successfully ran `python setup.py clean`"
249-
${CONDA_RUN} python setup.py bdist_wheel
260+
if [[ ${{ inputs.is-jetpack }} == false ]]; then
261+
${CONDA_RUN} python setup.py bdist_wheel
262+
else
263+
${CONDA_RUN} python setup.py bdist_wheel --jetpack --plat-name=linux_tegra_aarch64
264+
fi
250265
- name: Repair Manylinux_2_28 Wheel
251266
shell: bash -l {0}
252267
env:
@@ -272,6 +287,7 @@ jobs:
272287
script: ${{ inputs.post-script }}
273288
- name: Smoke Test
274289
shell: bash -l {0}
290+
if: ${{ inputs.is-jetpack == false }}
275291
env:
276292
PACKAGE_NAME: ${{ inputs.package-name }}
277293
SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }}
@@ -316,7 +332,8 @@ jobs:
316332
upload:
317333
needs: build
318334
uses: pytorch/test-infra/.github/workflows/_binary_upload.yml@main
319-
if: always()
335+
# only upload to pytorch index for non jetpack builds
336+
if: ${{ inputs.is-jetpack == false }}
320337
with:
321338
repository: ${{ inputs.repository }}
322339
ref: ${{ inputs.ref }}

MODULE.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ http_archive(
8787
urls = ["https://download.pytorch.org/libtorch/nightly/cu128/libtorch-win-shared-with-deps-latest.zip"],
8888
)
8989

90+
http_archive(
91+
name = "torch_l4t",
92+
build_file = "@//third_party/libtorch:BUILD",
93+
strip_prefix = "torch",
94+
type = "zip",
95+
urls = ["https://pypi.jetson-ai-lab.dev/jp6/cu126/+f/6ef/f643c0a7acda9/torch-2.7.0-cp310-cp310-linux_aarch64.whl"],
96+
sha256 = "6eff643c0a7acda92734cc798338f733ff35c7df1a4434576f5ff7c66fc97319"
97+
)
98+
9099
# Download these tarballs manually from the NVIDIA website
91100
# Either place them in the distdir directory in third_party and use the --distdir flag
92101
# or modify the urls to "file:///<PATH TO TARBALL>/<TARBALL NAME>.tar.gz

core/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ cc_library(
6666
}) + select({
6767
":windows": ["@libtorch_win//:libtorch"],
6868
":use_torch_whl": ["@torch_whl//:libtorch"],
69+
":jetpack": ["@torch_l4t//:libtorch"],
6970
"//conditions:default": ["@libtorch"],
7071
}),
7172
alwayslink = True,

core/conversion/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ cc_library(
6161
}) + select({
6262
":windows": ["@libtorch_win//:libtorch"],
6363
":use_torch_whl": ["@torch_whl//:libtorch"],
64+
":jetpack": ["@torch_l4t//:libtorch"],
6465
"//conditions:default": ["@libtorch"],
6566
}),
6667
alwayslink = True,

core/conversion/conversionctx/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ cc_library(
5656
}) + select({
5757
":windows": ["@libtorch_win//:libtorch"],
5858
":use_torch_whl": ["@torch_whl//:libtorch"],
59+
":jetpack": ["@torch_l4t//:libtorch"],
5960
"//conditions:default": ["@libtorch"],
6061
}),
6162
alwayslink = True,

core/conversion/converters/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ cc_library(
5656
}) + select({
5757
":windows": ["@libtorch_win//:libtorch"],
5858
":use_torch_whl": ["@torch_whl//:libtorch"],
59+
":jetpack": ["@torch_l4t//:libtorch"],
5960
"//conditions:default": ["@libtorch"],
6061
}),
6162
alwayslink = True,
@@ -81,6 +82,7 @@ cc_library(
8182
}) + select({
8283
":windows": ["@libtorch_win//:libtorch"],
8384
":use_torch_whl": ["@torch_whl//:libtorch"],
85+
":jetpack": ["@torch_l4t//:libtorch"],
8486
"//conditions:default": ["@libtorch"],
8587
}),
8688
alwayslink = True,
@@ -143,6 +145,7 @@ cc_library(
143145
}) + select({
144146
":windows": ["@libtorch_win//:libtorch"],
145147
":use_torch_whl": ["@torch_whl//:libtorch"],
148+
":jetpack": ["@torch_l4t//:libtorch"],
146149
"//conditions:default": ["@libtorch"],
147150
}),
148151
alwayslink = True,

core/conversion/evaluators/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ cc_library(
6262
}) + select({
6363
":windows": ["@libtorch_win//:libtorch"],
6464
":use_torch_whl": ["@torch_whl//:libtorch"],
65+
":jetpack": ["@torch_l4t//:libtorch"],
6566
"//conditions:default": ["@libtorch"],
6667
}),
6768
alwayslink = True,

core/conversion/tensorcontainer/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ cc_library(
5555
}) + select({
5656
":windows": ["@libtorch_win//:libtorch"],
5757
":use_torch_whl": ["@torch_whl//:libtorch"],
58+
":jetpack": ["@torch_l4t//:libtorch"],
5859
"//conditions:default": ["@libtorch"],
5960
}),
6061
alwayslink = True,

core/conversion/var/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ cc_library(
5858
}) + select({
5959
":windows": ["@libtorch_win//:libtorch"],
6060
":use_torch_whl": ["@torch_whl//:libtorch"],
61+
":jetpack": ["@torch_l4t//:libtorch"],
6162
"//conditions:default": ["@libtorch"],
6263
}),
6364
alwayslink = True,

core/ir/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ cc_library(
5858
}) + select({
5959
":windows": ["@libtorch_win//:libtorch"],
6060
":use_torch_whl": ["@torch_whl//:libtorch"],
61+
":jetpack": ["@torch_l4t//:libtorch"],
6162
"//conditions:default": ["@libtorch"],
6263
}),
6364
alwayslink = True,

core/lowering/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ cc_library(
6060
}) + select({
6161
":windows": ["@libtorch_win//:libtorch"],
6262
":use_torch_whl": ["@torch_whl//:libtorch"],
63+
":jetpack": ["@torch_l4t//:libtorch"],
6364
"//conditions:default": ["@libtorch"],
6465
}),
6566
alwayslink = True,

core/lowering/passes/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ cc_library(
7878
] + select({
7979
":use_torch_whl": ["@torch_whl//:libtorch"],
8080
":windows": ["@libtorch_win//:libtorch"],
81+
":jetpack": ["@torch_l4t//:libtorch"],
8182
"//conditions:default": ["@libtorch"],
8283
}),
8384
alwayslink = True,

0 commit comments

Comments
 (0)