-
Notifications
You must be signed in to change notification settings - Fork 358
260 lines (251 loc) · 9.85 KB
/
release-wheel-linux.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: Build Release Wheel Artifacts on Linux
on:
workflow_call:
inputs:
repository:
description: 'Repository to checkout, defaults to ""'
default: ""
type: string
ref:
description: 'Reference to checkout, defaults to "nightly"'
default: "nightly"
type: string
test-infra-repository:
description: "Test infra repository to use"
default: "pytorch/test-infra"
type: string
test-infra-ref:
description: "Test infra reference to use"
default: ""
type: string
build-matrix:
description: "Build matrix to utilize"
default: ""
type: string
pre-script:
description: "Pre script to run prior to build"
default: ""
type: string
post-script:
description: "Post script to run prior to build"
default: ""
type: string
smoke-test-script:
description: "Script for Smoke Test for a specific domain"
default: ""
type: string
env-var-script:
description: "Script that sets Domain-Specific Environment Variables"
default: ""
type: string
package-name:
description: "Name of the actual python package that is imported"
default: ""
type: string
trigger-event:
description: "Trigger Event in caller that determines whether or not to upload"
default: ""
type: string
cache-path:
description: "The path(s) on the runner to cache or restore. The path is relative to repository."
default: ""
type: string
cache-key:
description: "The key created when saving a cache and the key used to search for a cache."
default: ""
type: string
architecture:
description: Architecture to build for x86_64 for default Linux, or aarch64 for Linux aarch64 builds
required: false
type: string
default: x86_64
submodules:
description: Works as stated in actions/checkout, but the default value is recursive
required: false
type: string
default: recursive
setup-miniconda:
description: Set to true if setup-miniconda is needed
required: false
type: boolean
default: true
cxx11-tarball-release:
description: "Flag whether this is the cxx11 tarball release"
required: true
type: string
default: "false"
permissions:
id-token: write
contents: read
jobs:
release:
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.build-matrix) }}
env:
PYTHON_VERSION: ${{ matrix.python_version }}
PACKAGE_TYPE: wheel
REPOSITORY: ${{ inputs.repository }}
REF: ${{ inputs.ref }}
CU_VERSION: ${{ matrix.desired_cuda }}
UPLOAD_TO_BASE_BUCKET: ${{ matrix.upload_to_base_bucket }}
ARCH: ${{ inputs.architecture }}
name: release_${{ matrix.build_name }}
runs-on: ${{ matrix.validation_runner }}
container:
image: ${{ matrix.container_image }}
options: ${{ matrix.gpu_arch_type == 'cuda' && '--gpus all' || ' ' }}
# If a build is taking longer than 120 minutes on these runners we need
# to have a conversation
timeout-minutes: 120
steps:
- name: Clean workspace
shell: bash -l {0}
run: |
set -x
echo "::group::Cleanup debug output"
rm -rf "${GITHUB_WORKSPACE}"
mkdir -p "${GITHUB_WORKSPACE}"
if [[ "${{ inputs.architecture }}" = "aarch64" ]]; then
rm -rf "${RUNNER_TEMP}/*"
fi
echo "::endgroup::"
- uses: actions/checkout@v4
with:
# Support the use case where we need to checkout someone's fork
repository: ${{ inputs.test-infra-repository }}
ref: ${{ inputs.test-infra-ref }}
path: test-infra
- uses: actions/checkout@v4
if: ${{ env.ARCH == 'aarch64' }}
with:
# Support the use case where we need to checkout someone's fork
repository: "pytorch/builder"
ref: "main"
path: builder
- name: Set linux aarch64 CI
if: ${{ inputs.architecture == 'aarch64' }}
shell: bash -l {0}
env:
DESIRED_PYTHON: ${{ matrix.python_version }}
run: |
set +e
# TODO: This is temporary aarch64 setup script, this should be integrated into aarch64 docker.
${GITHUB_WORKSPACE}/builder/aarch64_linux/aarch64_ci_setup.sh
echo "/opt/conda/bin" >> $GITHUB_PATH
set -e
- uses: ./test-infra/.github/actions/set-channel
- name: Set PYTORCH_VERSION
if: ${{ env.CHANNEL == 'test' }}
run: |
# When building RC, set the version to be the current candidate version,
# otherwise, leave it alone so nightly will pick up the latest
echo "PYTORCH_VERSION=${{ matrix.stable_version }}" >> "${GITHUB_ENV}"
- uses: ./test-infra/.github/actions/setup-binary-builds
env:
PLATFORM: ${{ inputs.architecture == 'aarch64' && 'linux-aarch64' || ''}}
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
submodules: ${{ inputs.submodules }}
setup-miniconda: ${{ inputs.setup-miniconda }}
python-version: ${{ env.PYTHON_VERSION }}
cuda-version: ${{ env.CU_VERSION }}
arch: ${{ env.ARCH }}
- name: Combine Env Var and Build Env Files
if: ${{ inputs.env-var-script != '' }}
working-directory: ${{ inputs.repository }}
shell: bash -l {0}
run: |
cat "${{ inputs.env-var-script }}" >> "${BUILD_ENV_FILE}"
- name: Install torch dependency
shell: bash -l {0}
run: |
set -x
# shellcheck disable=SC1090
source "${BUILD_ENV_FILE}"
# shellcheck disable=SC2086
${CONDA_RUN} ${PIP_INSTALL_TORCH}
- name: Run Pre-Script with Caching
if: ${{ inputs.pre-script != '' }}
uses: ./test-infra/.github/actions/run-script-with-cache
with:
cache-path: ${{ inputs.cache-path }}
cache-key: ${{ inputs.cache-key }}
repository: ${{ inputs.repository }}
script: ${{ inputs.pre-script }}
- name: Build clean
working-directory: ${{ inputs.repository }}
shell: bash -l {0}
run: |
set -x
source "${BUILD_ENV_FILE}"
${CONDA_RUN} python setup.py clean
- name: Build the wheel (bdist_wheel)
working-directory: ${{ inputs.repository }}
shell: bash -l {0}
run: |
set -x
source "${BUILD_ENV_FILE}"
# BUILD_VERSION example: 2.4.0+cu121, we don't want the +cu121 part, so remove +cu121
BUILD_VERSION=${BUILD_VERSION%+*}
TRT_VERSION=$(cat dev_dep_versions.yml | grep __tensorrt_version__ | sed 's/__tensorrt_version__: //g' | sed 's/"//g')
mkdir release
mkdir release/tarball
mkdir release/wheel
if [[ "${{ inputs.cxx11-tarball-release }}" == "true" ]]; then
bazel build //:libtorchtrt --compilation_mode opt --config=linux
cp bazel-bin/libtorchtrt.tar.gz \
release/tarball/libtorchtrt-${BUILD_VERSION}-tensorrt${TRT_VERSION}-cuda${CU_VERSION:2}-libtorch${PYTORCH_VERSION}-x86_64-linux.tar.gz
else
${CONDA_RUN} python setup.py bdist_wheel --release
cp bazel-bin/libtorchtrt.tar.gz \
release/tarball/libtorchtrt-${BUILD_VERSION}-pre-cxx11-abi-tensorrt${TRT_VERSION}-cuda${CU_VERSION:2}-libtorch${PYTORCH_VERSION}-x86_64-linux.tar.gz
${CONDA_RUN} python -m pip install auditwheel
${CONDA_RUN} python -m auditwheel repair \
$(cat py/ci/soname_excludes.params) \
--plat manylinux_2_34_x86_64 \
dist/torch_tensorrt-*-linux_x86_64.whl
${CONDA_RUN} python -m zipfile --list wheelhouse/torch_tensorrt-*_x86_64.whl
cp wheelhouse/torch_tensorrt-*_x86_64.whl release/wheel/
fi
- name: Run Post-Script
if: ${{ inputs.post-script != '' }}
uses: ./test-infra/.github/actions/run-script-with-cache
with:
repository: ${{ inputs.repository }}
script: ${{ inputs.post-script }}
- name: Smoke Test
shell: bash -l {0}
env:
PACKAGE_NAME: ${{ inputs.package-name }}
SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }}
run: |
set -x
source "${BUILD_ENV_FILE}"
# TODO: add smoke test for the auditwheel tarball built
# NB: Only upload to GitHub after passing smoke tests
- name: Upload wheel to GitHub
if: ${{ inputs.cxx11-tarball-release != 'true' }}
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ inputs.repository }}/release/wheel/
- name: Upload pre-cxx11 tarball to GitHub
if: ${{ inputs.cxx11-tarball-release != 'true' && env.PYTHON_VERSION == '3.10' }}
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: pre-cxx11-tarball-${{ env.PYTHON_VERSION }}-${{ env.CU_VERSION }}
path: ${{ inputs.repository }}/release/tarball/
- name: Upload cxx11 tarball to GitHub
if: ${{ inputs.cxx11-tarball-release == 'true' }}
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: cxx11-tarball-${{ env.PYTHON_VERSION }}-${{ env.CU_VERSION }}
path: ${{ inputs.repository }}/release/tarball/
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }}-${{ inputs.cxx11-tarball-release }}
cancel-in-progress: true