forked from NVIDIA/cuda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
422 lines (370 loc) · 17.9 KB
/
Copy pathtest-wheel-linux.yml
File metadata and controls
422 lines (370 loc) · 17.9 KB
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
name: "CI: Test wheels"
on:
workflow_call:
inputs:
build-type:
type: string
required: true
host-platform:
type: string
required: true
build-ctk-ver:
type: string
required: true
matrix_filter:
type: string
default: "."
nruns:
type: number
default: 1
# When true, cuda.bindings tests (and the Cython tests that depend on
# them) are skipped even when CTK majors match. Callers set this based
# on the output of the detect-changes job in ci.yml so PRs that only
# touch unrelated modules avoid the expensive bindings test suite.
skip-bindings-test:
type: boolean
default: false
run-id:
description: >
Workflow run ID to download artifacts from.
Defaults to the current run when empty.
type: string
default: ''
test-mode:
description: >
Test mode: 'standard' (default), 'nightly-pytorch', or
'nightly-numba-cuda'.
type: string
default: 'standard'
sha:
description: >
Commit SHA used to construct artifact names.
Defaults to github.sha (current run) when empty.
type: string
default: ''
defaults:
run:
shell: bash --noprofile --norc -xeuo pipefail {0}
jobs:
compute-matrix:
runs-on: ubuntu-latest
env:
BUILD_TYPE: ${{ inputs.build-type }}
ARCH: ${{ (inputs.host-platform == 'linux-64' && 'amd64') ||
(inputs.host-platform == 'linux-aarch64' && 'arm64') }}
outputs:
MATRIX: ${{ steps.compute-matrix.outputs.MATRIX }}
OLD_BRANCH: ${{ steps.compute-matrix.outputs.OLD_BRANCH }}
steps:
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Validate Test Type
run: |
if [[ "$BUILD_TYPE" != "pull-request" ]] && [[ "$BUILD_TYPE" != "nightly" ]] && [[ "$BUILD_TYPE" != "branch" ]]; then
echo "Invalid build type! Must be one of 'nightly', 'pull-request', or 'branch'."
exit 1
fi
- name: Compute Python Test Matrix
id: compute-matrix
run: |
# Use the nightly matrix for branch tests
MATRIX_TYPE="${BUILD_TYPE}"
if [[ "${MATRIX_TYPE}" == "branch" ]]; then
MATRIX_TYPE="nightly"
fi
# Read base matrix from YAML file for the specific architecture
TEST_MATRIX=$(yq -o json ".linux[\"${MATRIX_TYPE}\"] | map(select(.ARCH == \"${ARCH}\"))" ci/test-matrix.yml)
# Apply matrix filter; reject custom DRIVER + FLAVOR=wsl (the
# in-container driver swap doesn't work under WSL); add a
# RUNNER_DRIVER field that maps any custom version back to
# 'latest' (the install script swaps the driver itself, so we
# need to land on the runner that ships with the most recent
# pre-installed driver); wrap in include structure.
MATRIX=$(echo "$TEST_MATRIX" | jq -c '${{ inputs.matrix_filter }} | if any(.[]; .DRIVER != "latest" and .DRIVER != "earliest" and .FLAVOR == "wsl") then "Error: custom DRIVER is not supported with FLAVOR=wsl\n" | halt_error(1) else . end | map(. + {RUNNER_DRIVER: (if .DRIVER == "latest" or .DRIVER == "earliest" then .DRIVER else "latest" end)}) | if (. | length) > 0 then {include: .} else "Error: Empty matrix\n" | halt_error(1) end')
echo "MATRIX=${MATRIX}" | tee --append "${GITHUB_OUTPUT}"
# This job has yq already installed, so let's do it here
OLD_BRANCH=$(yq '.backport_branch' ci/versions.yml)
echo "OLD_BRANCH=${OLD_BRANCH}" >> "$GITHUB_OUTPUT"
test:
name: Python ${{ matrix.PY_VER }}, CUDA ${{ matrix.CUDA_VER }} (${{ (matrix.LOCAL_CTK == '1' && 'local') || 'wheels' }}), GPU ${{ matrix.GPU }}${{ matrix.GPU_COUNT != '1' && format(' (x{0})', matrix.GPU_COUNT) || '' }}${{ matrix.FLAVOR && format(', {0}', matrix.FLAVOR) || '' }}${{ matrix.ENV.TORCH_VER && format(', {0}+{1}', matrix.ENV.TORCH_VER, matrix.ENV.TORCH_CUDA) || '' }}${{ matrix.ENV.MODE == 'nightly-numba-cuda' && ', latest' || '' }}
timeout-minutes: 60
needs: compute-matrix
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.compute-matrix.outputs.MATRIX) }}
runs-on: "${{ matrix.FLAVOR || 'linux' }}-${{ matrix.ARCH }}-gpu-${{ matrix.GPU }}-${{ matrix.RUNNER_DRIVER }}-${{ matrix.GPU_COUNT }}"
# TODO: remove continue-on-error once 3.15 is officially supported
continue-on-error: ${{ startsWith(matrix.PY_VER, '3.15') }}
# The build stage could fail but we want the CI to keep moving.
if: ${{ github.repository_owner == 'nvidia' && !cancelled() }}
# Our self-hosted runners require a container
# TODO: use a different (nvidia?) container
container:
# Custom-DRIVER rows need --privileged --pid=host so install_gpu_driver.sh
# can nsenter to the host for the install + refresh the toolkit bind mounts
# back inside the container. Stock options for latest/earliest rows.
options: ${{ ((matrix.DRIVER == 'latest' || matrix.DRIVER == 'earliest') && '-u root --security-opt seccomp=unconfined --shm-size 16g') || '-u root --security-opt seccomp=unconfined --shm-size 16g --privileged --pid=host' }}
image: ubuntu:24.04
env:
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
PIP_CACHE_DIR: "/tmp/pip-cache"
steps:
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup proxy cache
uses: nv-gha-runners/setup-proxy-cache@main
continue-on-error: true
- name: Install dependencies
uses: ./.github/actions/install_unix_deps
continue-on-error: false
with:
# for artifact fetching, graphics libs, g++ required for cffi in
# example; util-linux for `nsenter` (custom-DRIVER rows re-exec
# install_gpu_driver.sh onto the host through nsenter)
dependencies: "jq wget libgl1 libegl1 g++ util-linux"
dependent_exes: "jq wget"
- name: Install GPU driver
if: ${{ matrix.DRIVER != 'latest' && matrix.DRIVER != 'earliest' }}
env:
DRIVER: ${{ matrix.DRIVER }}
GPU_TYPE: ${{ matrix.GPU }}
run: ./ci/tools/install_gpu_driver.sh
- name: Ensure GPU is working
run: nvidia-smi
- name: Set environment variables
env:
BUILD_CUDA_VER: ${{ inputs.build-ctk-ver }}
CUDA_VER: ${{ matrix.CUDA_VER }}
HOST_PLATFORM: ${{ inputs.host-platform }}
LOCAL_CTK: ${{ matrix.LOCAL_CTK }}
PY_VER: ${{ matrix.PY_VER }}
SHA: ${{ inputs.sha || github.sha }}
SKIP_BINDINGS_TEST_OVERRIDE: ${{ inputs.skip-bindings-test && '1' || '0' }}
run: ./ci/tools/env-vars test
- name: Apply extra matrix environment variables
if: ${{ matrix.ENV }}
env:
MATRIX_ENV: ${{ toJSON(matrix.ENV) }}
run: echo "$MATRIX_ENV" | jq -r 'to_entries[] | "\(.key)=\(.value)"' >> "$GITHUB_ENV"
- name: Download cuda-pathfinder build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: cuda-pathfinder-wheel
path: ./cuda_pathfinder
run-id: ${{ inputs.run-id || github.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Download cuda-python build artifacts
if: ${{ env.BINDINGS_SOURCE == 'main' }}
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: cuda-python-wheel
path: .
run-id: ${{ inputs.run-id || github.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Download cuda.bindings build artifacts
if: ${{ env.BINDINGS_SOURCE == 'main' }}
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
run-id: ${{ inputs.run-id || github.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Download cuda-python & cuda.bindings build artifacts from the prior branch
if: ${{ env.BINDINGS_SOURCE == 'backport' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# See https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt.
# gh is needed for artifact fetching.
mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt update \
&& apt install gh -y
OLD_BRANCH=${{ needs.compute-matrix.outputs.OLD_BRANCH }}
OLD_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda*-${{ inputs.host-platform }}*"
LATEST_PRIOR_RUN_ID=$(./ci/tools/lookup-run-id --branch "${OLD_BRANCH}" NVIDIA/cuda-python "CI")
gh run download $LATEST_PRIOR_RUN_ID -p ${OLD_BASENAME} -R NVIDIA/cuda-python
rm -rf ${OLD_BASENAME}-tests # exclude cython test artifacts
ls -al $OLD_BASENAME
mkdir -p "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"
mv $OLD_BASENAME/*.whl "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"/
rmdir $OLD_BASENAME
gh run download $LATEST_PRIOR_RUN_ID -p cuda-python-wheel -R NVIDIA/cuda-python
ls -al cuda-python-wheel
mv cuda-python-wheel/*.whl .
rmdir cuda-python-wheel
- name: Display structure of downloaded cuda-python artifacts
if: ${{ env.BINDINGS_SOURCE != 'published' }}
run: |
pwd
ls -lah cuda_python*.whl cuda_pathfinder/
- name: Display structure of downloaded cuda.bindings artifacts
if: ${{ env.BINDINGS_SOURCE != 'published' }}
run: |
pwd
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
- name: Download cuda.bindings Cython tests
if: ${{ env.SKIP_CYTHON_TEST == '0' }}
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}-tests
path: ${{ env.CUDA_BINDINGS_CYTHON_TESTS_DIR }}
run-id: ${{ inputs.run-id || github.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Display structure of downloaded cuda.bindings Cython tests
if: ${{ env.SKIP_CYTHON_TEST == '0' }}
run: |
pwd
ls -lahR $CUDA_BINDINGS_CYTHON_TESTS_DIR
- name: Download cuda.core build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
run-id: ${{ inputs.run-id || github.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Display structure of downloaded cuda.core build artifacts
run: |
pwd
ls -lahR $CUDA_CORE_ARTIFACTS_DIR
- name: Download cuda.core Cython tests
if: ${{ env.SKIP_CYTHON_TEST == '0' }}
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}-tests
path: ${{ env.CUDA_CORE_CYTHON_TESTS_DIR }}
run-id: ${{ inputs.run-id || github.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Display structure of downloaded cuda.core Cython tests
if: ${{ env.SKIP_CYTHON_TEST == '0' }}
run: |
pwd
ls -lahR $CUDA_CORE_CYTHON_TESTS_DIR
- name: Download cuda.core test binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}-test-binaries
path: ${{ env.CUDA_CORE_TEST_BINARIES_DIR }}
run-id: ${{ inputs.run-id || github.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Display structure of downloaded cuda.core test binaries
run: |
pwd
ls -lahR $CUDA_CORE_TEST_BINARIES_DIR
- name: Set up Python ${{ matrix.PY_VER }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.PY_VER }}
# TODO: remove allow-prereleases once 3.15 is officially supported
allow-prereleases: ${{ startsWith(matrix.PY_VER, '3.15') }}
env:
# we use self-hosted runners on which setup-python behaves weirdly (Python include can't be found)...
AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache"
- name: Set up mini CTK
if: ${{ matrix.LOCAL_CTK == '1' }}
uses: ./.github/actions/fetch_ctk
continue-on-error: false
with:
host-platform: ${{ inputs.host-platform }}
cuda-version: ${{ matrix.CUDA_VER }}
# TODO: remove the numpy wheel steps once 3.15 is officially supported
- name: Download numpy wheel (pre-release Python)
if: ${{ startsWith(matrix.PY_VER, '3.15') }}
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: numpy-python${{ env.PYTHON_VERSION_FORMATTED }}-${{ inputs.host-platform }}
path: numpy-wheel
- name: Install numpy wheel (pre-release Python)
if: ${{ startsWith(matrix.PY_VER, '3.15') }}
run: pip install numpy-wheel/*.whl
- name: Set up latest cuda_sanitizer_api
if: ${{ env.SETUP_SANITIZER == '1' }}
uses: ./.github/actions/fetch_ctk
continue-on-error: false
with:
host-platform: ${{ inputs.host-platform }}
cuda-version: ${{ env.LATEST_CUDA_VERSION }}
cuda-components: "cuda_sanitizer_api"
- name: Set up compute-sanitizer
run: setup-sanitizer
- name: Set up test repetition on nightly runs
run: echo "PYTEST_ADDOPTS=\"--count=${{ inputs.nruns }}\"" >> "$GITHUB_ENV"
# ── Standard test steps (skipped for nightly modes) ──
- name: Run cuda.pathfinder tests with see_what_works
if: ${{ inputs.test-mode == 'standard' }}
env:
CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS: see_what_works
CUDA_PATHFINDER_TEST_FIND_NVIDIA_HEADERS_STRICTNESS: see_what_works
CUDA_PATHFINDER_TEST_FIND_NVIDIA_BITCODE_LIB_STRICTNESS: see_what_works
run: run-tests pathfinder
- name: Run cuda.bindings tests
if: ${{ inputs.test-mode == 'standard' && env.SKIP_CUDA_BINDINGS_TEST == '0' }}
env:
CUDA_VER: ${{ matrix.CUDA_VER }}
LOCAL_CTK: ${{ matrix.LOCAL_CTK }}
run: run-tests bindings
- name: Run cuda.bindings benchmarks (smoke test)
if: ${{ inputs.test-mode == 'standard' && env.SKIP_CUDA_BINDINGS_TEST == '0' }}
run: |
pip install pyperf
pushd benchmarks/cuda_bindings
python run_pyperf.py --debug-single-value
popd
- name: Run cuda.core tests
if: ${{ inputs.test-mode == 'standard' }}
env:
CUDA_VER: ${{ matrix.CUDA_VER }}
LOCAL_CTK: ${{ matrix.LOCAL_CTK }}
run: run-tests core
- name: Ensure cuda-python installable
if: ${{ inputs.test-mode == 'standard' && env.BINDINGS_SOURCE == 'main' }}
run: |
if [[ "${{ matrix.LOCAL_CTK }}" == 1 ]]; then
pip install --only-binary=:all: cuda_python*.whl
else
pip install --only-binary=:all: $(ls cuda_python*.whl)[all]
fi
- name: Install cuda.pathfinder extra wheels for testing
if: ${{ inputs.test-mode == 'standard' }}
run: |
set -euo pipefail
pushd cuda_pathfinder
pip install --only-binary=:all: -v ./*.whl --group "test-cu${TEST_CUDA_MAJOR}"
pip list
popd
- name: Run cuda.pathfinder tests with all_must_work
if: ${{ inputs.test-mode == 'standard' }}
env:
CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS: all_must_work
CUDA_PATHFINDER_TEST_FIND_NVIDIA_HEADERS_STRICTNESS: all_must_work
CUDA_PATHFINDER_TEST_FIND_NVIDIA_BITCODE_LIB_STRICTNESS: all_must_work
run: run-tests pathfinder
# ── Nightly: install wheels + optional dep together ──
- name: Install cuda-python wheels + PyTorch
if: ${{ inputs.test-mode == 'nightly-pytorch' }}
env:
CUDA_VER: ${{ matrix.CUDA_VER }}
LOCAL_CTK: ${{ matrix.LOCAL_CTK }}
run: run-tests nightly-pytorch
- name: Install cuda-python wheels + numba-cuda
if: ${{ inputs.test-mode == 'nightly-numba-cuda' }}
env:
CUDA_VER: ${{ matrix.CUDA_VER }}
LOCAL_CTK: ${{ matrix.LOCAL_CTK }}
run: run-tests nightly-numba-cuda
# ── Nightly: run tests ──
- name: Run PyTorch interop tests
if: ${{ inputs.test-mode == 'nightly-pytorch' }}
run: |
pushd cuda_core
pytest -rxXs -v --durations=0 tests/test_utils.py tests/example_tests/
popd
- name: Run numba-cuda tests
if: ${{ inputs.test-mode == 'nightly-numba-cuda' }}
run: python -m numba.runtests numba.cuda.tests