forked from NVIDIA/cuda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
268 lines (235 loc) · 9.94 KB
/
build-wheel.yml
File metadata and controls
268 lines (235 loc) · 9.94 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
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
on:
workflow_call:
inputs:
host-platform:
required: true
type: string
cuda-version:
required: true
type: string
defaults:
run:
shell: bash --noprofile --norc -xeuo pipefail {0}
permissions:
contents: read # This is required for actions/checkout
jobs:
build:
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
name: py${{ matrix.python-version }}
runs-on: ${{ (inputs.host-platform == 'linux-64' && 'linux-amd64-cpu8') ||
(inputs.host-platform == 'linux-aarch64' && 'linux-arm64-cpu8') ||
(inputs.host-platform == 'win-64' && 'windows-2022') }}
steps:
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Setup proxy cache
uses: nv-gha-runners/setup-proxy-cache@main
continue-on-error: true
# Skip the cache on Windows nodes outside of our org.
if: ${{ inputs.host-platform != 'win-64' }}
- name: Set up Python
id: setup-python1
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
# WAR: setup-python is not relocatable, and cibuildwheel hard-wires to 3.12...
# see https://github.com/actions/setup-python/issues/871
python-version: "3.12"
- name: Set up MSVC
if: ${{ startsWith(inputs.host-platform, 'win') }}
uses: ilammy/msvc-dev-cmd@v1 # TODO: ask admin to allow pinning commits
- name: Set environment variables
env:
CUDA_VER: ${{ inputs.cuda-version }}
HOST_PLATFORM: ${{ inputs.host-platform }}
PY_VER: ${{ matrix.python-version }}
SHA: ${{ github.sha }}
run: ./ci/tools/env-vars build
- name: Dump environment
run: |
env
- name: Install twine
run: |
pip install twine
# To keep the build workflow simple, all matrix jobs will build a wheel for later use within this workflow.
- name: Build and check cuda.pathfinder wheel
run: |
pushd cuda_pathfinder
pip wheel -v --no-deps .
popd
- name: List the cuda.pathfinder artifacts directory
run: |
if [[ "${{ inputs.host-platform }}" == win* ]]; then
export CHOWN=chown
else
export CHOWN="sudo chown"
fi
$CHOWN -R $(whoami) cuda_pathfinder/*.whl
ls -lahR cuda_pathfinder
# We only need/want a single pure python wheel, pick linux-64 index 0.
# This is what we will use for testing & releasing.
- name: Check cuda.pathfinder wheel
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
run: |
twine check cuda_pathfinder/*.whl
- name: Upload cuda.pathfinder build artifacts
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: cuda-pathfinder-wheel
path: cuda_pathfinder/*.whl
if-no-files-found: error
- name: Build cuda.core wheel
uses: pypa/cibuildwheel@352e01339f0a173aa2a3eb57f01492e341e83865 # v3.1.3
env:
CIBW_BUILD: ${{ env.CIBW_BUILD }}
CIBW_ARCHS_LINUX: "native"
CIBW_BUILD_VERBOSITY: 1
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair --namespace-pkg cuda -w {dest_dir} {wheel}"
CIBW_ENVIRONMENT: >
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
with:
package-dir: ./cuda_core/
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
- name: List the cuda.core artifacts directory
run: |
if [[ "${{ inputs.host-platform }}" == win* ]]; then
export CHOWN=chown
else
export CHOWN="sudo chown"
fi
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
- name: Check cuda.core wheel
run: |
twine check ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
- name: Upload cuda.core build artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
if-no-files-found: error
- name: Set up mini CTK
uses: ./.github/actions/fetch_ctk
continue-on-error: false
with:
host-platform: ${{ inputs.host-platform }}
cuda-version: ${{ inputs.cuda-version }}
- name: Build cuda.bindings wheel
uses: pypa/cibuildwheel@352e01339f0a173aa2a3eb57f01492e341e83865 # v3.1.3
env:
CIBW_BUILD: ${{ env.CIBW_BUILD }}
CIBW_ARCHS_LINUX: "native"
CIBW_BUILD_VERBOSITY: 1
# CIBW mounts the host filesystem under /host
CIBW_ENVIRONMENT_LINUX: >
CUDA_PATH=/host/${{ env.CUDA_PATH }}
LIBRARY_PATH=/host/${{ env.CUDA_PATH }}/lib
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
CIBW_ENVIRONMENT_WINDOWS: >
CUDA_HOME="$(cygpath -w ${{ env.CUDA_PATH }})"
LIB="${CUDA_HOME}\\lib\\x64;${LIB}"
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair --namespace-pkg cuda -w {dest_dir} {wheel}"
with:
package-dir: ./cuda_bindings/
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
- name: List the cuda.bindings artifacts directory
run: |
if [[ "${{ inputs.host-platform }}" == win* ]]; then
export CHOWN=chown
else
export CHOWN="sudo chown"
fi
$CHOWN -R $(whoami) ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
ls -lahR ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
- name: Check cuda.bindings wheel
run: |
twine check ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
- name: Upload cuda.bindings build artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
if-no-files-found: error
# We only need/want a single pure python wheel, pick linux-64 index 0.
- name: Build and check cuda-python wheel
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
run: |
pushd cuda_python
pip wheel -v --no-deps .
twine check *.whl
popd
- name: List the cuda-python artifacts directory
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
run: |
if [[ "${{ inputs.host-platform }}" == win* ]]; then
export CHOWN=chown
else
export CHOWN="sudo chown"
fi
$CHOWN -R $(whoami) cuda_python/*.whl
ls -lahR cuda_python
- name: Upload cuda-python build artifacts
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: cuda-python-wheel
path: cuda_python/*.whl
if-no-files-found: error
- name: Set up Python
id: setup-python2
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
# workaround for actions/runner-images#12377 (the cached 3.13.4 is buggy on Windows)
python-version: ${{ matrix.python-version == '3.13' && '3.13.5' || matrix.python-version }}
- name: Set up Python include paths
run: |
if [[ "${{ inputs.host-platform }}" == linux* ]]; then
echo "CPLUS_INCLUDE_PATH=${Python3_ROOT_DIR}/include/python${{ matrix.python-version }}" >> $GITHUB_ENV
elif [[ "${{ inputs.host-platform }}" == win* ]]; then
echo "CL=/I\"${Python3_ROOT_DIR}\include\python${{ matrix.python-version }}\"" >> $GITHUB_ENV
fi
# For caching
echo "PY_EXT_SUFFIX=$(python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")" >> $GITHUB_ENV
- name: Install cuda.pathfinder (required for next step)
run: |
pip install cuda_pathfinder/*.whl
- name: Build cuda.bindings Cython tests
run: |
pip install $(ls ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl)[test]
pushd ${{ env.CUDA_BINDINGS_CYTHON_TESTS_DIR }}
bash build_tests.sh
popd
- name: Upload cuda.bindings Cython tests
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}-tests
path: ${{ env.CUDA_BINDINGS_CYTHON_TESTS_DIR }}/test_*${{ env.PY_EXT_SUFFIX }}
if-no-files-found: error
- name: Build cuda.core Cython tests
run: |
pip install $(ls ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl)[test]
pushd ${{ env.CUDA_CORE_CYTHON_TESTS_DIR }}
bash build_tests.sh
popd
- name: Upload cuda.core Cython tests
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}-tests
path: ${{ env.CUDA_CORE_CYTHON_TESTS_DIR }}/test_*${{ env.PY_EXT_SUFFIX }}
if-no-files-found: error