1
+ name : Build Torch-TensorRT wheel on Windows with Future TensorRT Versions
2
+
3
+ on :
4
+ workflow_call :
5
+ inputs :
6
+ repository :
7
+ description : ' Repository to checkout, defaults to ""'
8
+ default : " "
9
+ type : string
10
+ ref :
11
+ description : ' Reference to checkout, defaults to "nightly"'
12
+ default : " nightly"
13
+ type : string
14
+ test-infra-repository :
15
+ description : " Test infra repository to use"
16
+ default : " pytorch/test-infra"
17
+ type : string
18
+ test-infra-ref :
19
+ description : " Test infra reference to use"
20
+ default : " "
21
+ type : string
22
+ build-matrix :
23
+ description : " Build matrix to utilize"
24
+ default : " "
25
+ type : string
26
+ pre-script :
27
+ description : " Pre script to run prior to build"
28
+ default : " "
29
+ type : string
30
+ env-script :
31
+ description : " Script to setup environment variables for the build"
32
+ default : " "
33
+ type : string
34
+ wheel-build-params :
35
+ description : " Additional parameters for bdist_wheel"
36
+ default : " "
37
+ type : string
38
+ post-script :
39
+ description : " Post script to run prior to build"
40
+ default : " "
41
+ type : string
42
+ smoke-test-script :
43
+ description : " Script for Smoke Test for a specific domain"
44
+ default : " "
45
+ type : string
46
+ package-name :
47
+ description : " Name of the actual python package that is imported"
48
+ default : " "
49
+ type : string
50
+ trigger-event :
51
+ description : " Trigger Event in caller that determines whether or not to upload"
52
+ default : " "
53
+ type : string
54
+ cache-path :
55
+ description : " The path(s) on the runner to cache or restore. The path is relative to repository."
56
+ default : " "
57
+ type : string
58
+ cache-key :
59
+ description : " The key created when saving a cache and the key used to search for a cache."
60
+ default : " "
61
+ type : string
62
+ submodules :
63
+ description : " Works as stated in actions/checkout, but the default value is recursive"
64
+ required : false
65
+ type : string
66
+ default : recursive
67
+ timeout :
68
+ description : ' Timeout for the job (in minutes)'
69
+ default : 60
70
+ type : number
71
+
72
+ permissions :
73
+ id-token : write
74
+ contents : read
75
+
76
+ jobs :
77
+ build :
78
+ strategy :
79
+ fail-fast : false
80
+ matrix : ${{ fromJSON(inputs.build-matrix) }}
81
+ env :
82
+ PYTHON_VERSION : ${{ matrix.python_version }}
83
+ PACKAGE_TYPE : wheel
84
+ REPOSITORY : ${{ inputs.repository }}
85
+ REF : ${{ inputs.ref }}
86
+ CU_VERSION : ${{ matrix.desired_cuda }}
87
+ UPLOAD_TO_BASE_BUCKET : ${{ matrix.upload_to_base_bucket }}
88
+ ARCH : win_amd64
89
+ TENSORRT_STRIP_PREFIX : ${{ matrix.tensorrt.strip_prefix }}
90
+ TENSORRT_VERSION : ${{ matrix.tensorrt.version }}
91
+ TENSORRT_URLS : ${{ matrix.tensorrt.urls }}
92
+ TENSORRT_SHA256 : ${{ matrix.tensorrt.sha256 }}
93
+ UPLOAD_ARTIFACT_NAME : pytorch_tensorrt_${{ matrix.tensorrt.version }}_${{ matrix.python_version }}_${{ matrix.desired_cuda }}_win_amd64
94
+ name : build_tensorrt${{ matrix.tensorrt.version }}_py${{matrix.python_version}}_${{matrix.desired_cuda}}
95
+ runs-on : ${{ matrix.validation_runner }}
96
+ defaults :
97
+ run :
98
+ shell : bash -l {0}
99
+ # If a build is taking longer than 60 minutes on these runners we need
100
+ # to have a conversation
101
+ timeout-minutes : 120
102
+ steps :
103
+ - uses : actions/checkout@v3
104
+ with :
105
+ # Support the use case where we need to checkout someone's fork
106
+ repository : ${{ inputs.test-infra-repository }}
107
+ ref : ${{ inputs.test-infra-ref }}
108
+ path : test-infra
109
+ - uses : ./test-infra/.github/actions/setup-ssh
110
+ name : Setup SSH
111
+ with :
112
+ github-secret : ${{ secrets.GITHUB_TOKEN }}
113
+ activate-with-label : false
114
+ instructions : " SSH with rdesktop using ssh -L 3389:localhost:3389 %%username%%@%%hostname%%"
115
+ - name : Add Conda scripts to GitHub path
116
+ run : |
117
+ echo "C:/Jenkins/Miniconda3/Scripts" >> $GITHUB_PATH
118
+ - uses : ./test-infra/.github/actions/set-channel
119
+ - name : Set PYTORCH_VERSION
120
+ if : ${{ env.CHANNEL == 'test' }}
121
+ run : |
122
+ # When building RC, set the version to be the current candidate version,
123
+ # otherwise, leave it alone so nightly will pick up the latest
124
+ echo "PYTORCH_VERSION=${{ matrix.stable_version }}" >> "${GITHUB_ENV}"
125
+ - uses : ./test-infra/.github/actions/setup-binary-builds
126
+ with :
127
+ repository : ${{ inputs.repository }}
128
+ ref : ${{ inputs.ref }}
129
+ submodules : ${{ inputs.submodules }}
130
+ setup-miniconda : false
131
+ python-version : ${{ env.PYTHON_VERSION }}
132
+ cuda-version : ${{ env.CU_VERSION }}
133
+ arch : ${{ env.ARCH }}
134
+ - name : Install XPU support package
135
+ if : ${{ matrix.gpu_arch_type == 'xpu' }}
136
+ run : |
137
+ cmd //c .\\test-infra\\.github\\scripts\\install_xpu.bat
138
+ - name : Install torch dependency
139
+ run : |
140
+ source "${BUILD_ENV_FILE}"
141
+ # shellcheck disable=SC2086
142
+ ${CONDA_RUN} ${PIP_INSTALL_TORCH}
143
+ - name : Run Pre-Script with Caching
144
+ if : ${{ inputs.pre-script != '' }}
145
+ uses : ./test-infra/.github/actions/run-script-with-cache
146
+ with :
147
+ cache-path : ${{ inputs.cache-path }}
148
+ cache-key : ${{ inputs.cache-key }}
149
+ repository : ${{ inputs.repository }}
150
+ script : ${{ inputs.pre-script }}
151
+ is_windows : ' enabled'
152
+ - name : Build clean
153
+ working-directory : ${{ inputs.repository }}
154
+ env :
155
+ ENV_SCRIPT : ${{ inputs.env-script }}
156
+ run : |
157
+ source "${BUILD_ENV_FILE}"
158
+ if [[ -z "${ENV_SCRIPT}" ]]; then
159
+ ${CONDA_RUN} python setup.py clean
160
+ else
161
+ if [[ ! -f ${ENV_SCRIPT} ]]; then
162
+ echo "::error::Specified env-script file (${ENV_SCRIPT}) not found"
163
+ exit 1
164
+ else
165
+ ${CONDA_RUN} ${ENV_SCRIPT} python setup.py clean
166
+ fi
167
+ fi
168
+ - name : Build the wheel (bdist_wheel)
169
+ working-directory : ${{ inputs.repository }}
170
+ env :
171
+ ENV_SCRIPT : ${{ inputs.env-script }}
172
+ BUILD_PARAMS : ${{ inputs.wheel-build-params }}
173
+ run : |
174
+ source "${BUILD_ENV_FILE}"
175
+
176
+ if [[ "$CU_VERSION" == "cpu" ]]; then
177
+ # CUDA and CPU are ABI compatible on the CPU-only parts, so strip
178
+ # in this case
179
+ export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
180
+ else
181
+ export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//')"
182
+ fi
183
+
184
+ if [[ -z "${ENV_SCRIPT}" ]]; then
185
+ ${CONDA_RUN} python setup.py bdist_wheel
186
+ else
187
+ ${CONDA_RUN} ${ENV_SCRIPT} python setup.py bdist_wheel ${BUILD_PARAMS}
188
+ fi
189
+ - name : Run post-script
190
+ working-directory : ${{ inputs.repository }}
191
+ env :
192
+ POST_SCRIPT : ${{ inputs.post-script }}
193
+ ENV_SCRIPT : ${{ inputs.env-script }}
194
+ if : ${{ inputs.post-script != '' }}
195
+ run : |
196
+ set -euxo pipefail
197
+ source "${BUILD_ENV_FILE}"
198
+ ${CONDA_RUN} ${ENV_SCRIPT} ${POST_SCRIPT}
199
+ - name : Smoke Test
200
+ env :
201
+ ENV_SCRIPT : ${{ inputs.env-script }}
202
+ PACKAGE_NAME : ${{ inputs.package-name }}
203
+ SMOKE_TEST_SCRIPT : ${{ inputs.smoke-test-script }}
204
+ run : |
205
+ source "${BUILD_ENV_FILE}"
206
+ WHEEL_NAME=$(ls "${{ inputs.repository }}/dist/")
207
+ echo "$WHEEL_NAME"
208
+ ${CONDA_RUN} pip install "${{ inputs.repository }}/dist/$WHEEL_NAME"
209
+ if [[ ! -f "${{ inputs.repository }}"/${SMOKE_TEST_SCRIPT} ]]; then
210
+ echo "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT} not found"
211
+ ${CONDA_RUN} "${{ inputs.repository }}/${ENV_SCRIPT}" python -c "import ${PACKAGE_NAME}; print('package version is ', ${PACKAGE_NAME}.__version__)"
212
+ else
213
+ echo "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT} found"
214
+ ${CONDA_RUN} "${{ inputs.repository }}/${ENV_SCRIPT}" python "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT}"
215
+ fi
216
+ # NB: Only upload to GitHub after passing smoke tests
217
+ - name : Upload wheel to GitHub
218
+ continue-on-error : true
219
+ uses : actions/upload-artifact@v3
220
+ with :
221
+ name : ${{ env.UPLOAD_ARTIFACT_NAME }}
222
+ path : ${{ inputs.repository }}/dist/
223
+ - uses : ./test-infra/.github/actions/teardown-windows
224
+ if : always()
225
+ name : Teardown Windows
226
+
227
+ concurrency :
228
+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }}
229
+ cancel-in-progress : true
0 commit comments