Skip to content

Commit d95cd91

Browse files
committed
try to reuse cuda-bindings wheels for 3.13t/3.14/3.14t
1 parent 9e799e4 commit d95cd91

File tree

1 file changed

+72
-38
lines changed

1 file changed

+72
-38
lines changed

.github/workflows/build-wheel.yml

Lines changed: 72 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,13 @@ jobs:
119119
host-platform: ${{ inputs.host-platform }}
120120
cuda-version: ${{ inputs.cuda-version }}
121121

122-
# TODO: this currently builds against the public cuda.bindings wheel. Consider
123-
# building against the wheel from main instead (the below step).
124-
- name: Build cuda.core wheel
122+
- name: Build cuda.bindings wheel
125123
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
126124
with:
127-
package-dir: ./cuda_core/
128-
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
125+
package-dir: ./cuda_bindings/
126+
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
129127
env:
130128
CIBW_BUILD: ${{ env.CIBW_BUILD }}
131-
CIBW_ENVIRONMENT: >
132-
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_CUDA_MAJOR }}
133129
# CIBW mounts the host filesystem under /host
134130
CIBW_ENVIRONMENT_LINUX: >
135131
CUDA_PATH=/host/${{ env.CUDA_PATH }}
@@ -138,63 +134,67 @@ jobs:
138134
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
139135
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
140136
141-
- name: List the cuda.core artifacts directory and rename
137+
- name: List the cuda.bindings artifacts directory
142138
run: |
143139
if [[ "${{ inputs.host-platform }}" == win* ]]; then
144140
export CHOWN=chown
145141
else
146142
export CHOWN="sudo chown"
147143
fi
148-
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
144+
$CHOWN -R $(whoami) ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
145+
ls -lahR ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
149146
150-
# Rename wheel to include CUDA version suffix
151-
mkdir -p "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_CUDA_MAJOR}"
152-
for wheel in ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl; do
153-
if [[ -f "${wheel}" ]]; then
154-
base_name=$(basename "${wheel}" .whl)
155-
new_name="${base_name}.cu${BUILD_CUDA_MAJOR}.whl"
156-
mv "${wheel}" "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_CUDA_MAJOR}/${new_name}"
157-
echo "Renamed wheel to: ${new_name}"
158-
fi
159-
done
147+
- name: Check cuda.bindings wheel
148+
run: |
149+
twine check --strict ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
160150
161-
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
151+
- name: Upload cuda.bindings build artifacts
152+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
153+
with:
154+
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
155+
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
156+
if-no-files-found: error
162157

163-
- name: Build cuda.bindings wheel
158+
# TODO: ideally we want to build against public cuda-bindings
159+
- name: Build cuda.core wheel
164160
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
165161
with:
166-
package-dir: ./cuda_bindings/
167-
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
162+
package-dir: ./cuda_core/
163+
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
168164
env:
169165
CIBW_BUILD: ${{ env.CIBW_BUILD }}
170166
# CIBW mounts the host filesystem under /host
167+
CIBW_ENVIRONMENT: >
168+
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_CUDA_MAJOR }}
169+
PIP_FIND_LINKS=/host/${{ env.CUDA_CORE_ARTIFACTS_DIR }}
171170
CIBW_ENVIRONMENT_LINUX: >
172171
CUDA_PATH=/host/${{ env.CUDA_PATH }}
173172
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
174173
CIBW_ENVIRONMENT_WINDOWS: >
175174
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
176175
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
177176
178-
- name: List the cuda.bindings artifacts directory
177+
- name: List the cuda.core artifacts directory and rename
179178
run: |
180179
if [[ "${{ inputs.host-platform }}" == win* ]]; then
181180
export CHOWN=chown
182181
else
183182
export CHOWN="sudo chown"
184183
fi
185-
$CHOWN -R $(whoami) ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
186-
ls -lahR ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
184+
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
187185
188-
- name: Check cuda.bindings wheel
189-
run: |
190-
twine check --strict ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
186+
# Rename wheel to include CUDA version suffix
187+
mkdir -p "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_CUDA_MAJOR}"
188+
for wheel in ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl; do
189+
if [[ -f "${wheel}" ]]; then
190+
base_name=$(basename "${wheel}" .whl)
191+
new_name="${base_name}.cu${BUILD_CUDA_MAJOR}.whl"
192+
mv "${wheel}" "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_CUDA_MAJOR}/${new_name}"
193+
echo "Renamed wheel to: ${new_name}"
194+
fi
195+
done
191196
192-
- name: Upload cuda.bindings build artifacts
193-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
194-
with:
195-
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
196-
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
197-
if-no-files-found: error
197+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
198198
199199
# We only need/want a single pure python wheel, pick linux-64 index 0.
200200
- name: Build and check cuda-python wheel
@@ -288,18 +288,52 @@ jobs:
288288
cuda-version: ${{ inputs.prev-cuda-version }}
289289
cuda-path: "./cuda_toolkit_prev"
290290

291-
# TODO: this currently builds against the public cuda.bindings wheel. Consider
292-
# building against the wheel from the backport branch instead.
291+
# TODO: ideally we want to build against public cuda-bindings
292+
- name: Download cuda.bindings build artifacts from the prior branch
293+
if: ${{ matrix.python-version == '3.13t'
294+
|| matrix.python-version == '3.14'
295+
|| matrix.python-version == '3.14t' }}
296+
env:
297+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
298+
run: |
299+
if ! (command -v gh 2>&1 >/dev/null); then
300+
# See https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt.
301+
# gh is needed for artifact fetching.
302+
mkdir -p -m 755 /etc/apt/keyrings \
303+
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
304+
&& cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
305+
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
306+
&& 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 \
307+
&& apt update \
308+
&& apt install gh -y
309+
fi
310+
311+
OLD_BRANCH=$(cat .github/BACKPORT_BRANCH)
312+
OLD_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda*-${{ inputs.host-platform }}*"
313+
LATEST_PRIOR_RUN_ID=$(gh run list -b ${OLD_BRANCH} -L 1 -w "ci.yml" -s completed -R NVIDIA/cuda-python --json databaseId | jq '.[]| .databaseId')
314+
if [[ "$LATEST_PRIOR_RUN_ID" == "" ]]; then
315+
echo "LATEST_PRIOR_RUN_ID not found!"
316+
exit 1
317+
fi
318+
319+
gh run download $LATEST_PRIOR_RUN_ID -p ${OLD_BASENAME} -R NVIDIA/cuda-python
320+
rm -rf ${OLD_BASENAME}-tests # exclude cython test artifacts
321+
ls -al $OLD_BASENAME
322+
mkdir -p "${{ env.CUDA_CORE_ARTIFACTS_DIR }}"
323+
mv $OLD_BASENAME/*.whl "${{ env.CUDA_CORE_ARTIFACTS_DIR }}"
324+
rmdir $OLD_BASENAME
325+
293326
- name: Build cuda.core wheel
294327
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
295328
with:
296329
package-dir: ./cuda_core/
297330
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
298331
env:
299332
CIBW_BUILD: ${{ env.CIBW_BUILD }}
333+
# CIBW mounts the host filesystem under /host
300334
CIBW_ENVIRONMENT: >
301335
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_PREV_CUDA_MAJOR }}
302-
# CIBW mounts the host filesystem under /host
336+
PIP_FIND_LINKS=/host/${{ env.CUDA_CORE_ARTIFACTS_DIR }}
303337
CIBW_ENVIRONMENT_LINUX: >
304338
CUDA_PATH=/host/${{ env.CUDA_PATH }}
305339
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}

0 commit comments

Comments
 (0)