Skip to content

Commit 8a636e5

Browse files
committed
set up double-build CI workflow
1 parent e51f910 commit 8a636e5

File tree

7 files changed

+141
-28
lines changed

7 files changed

+141
-28
lines changed

.github/actions/fetch_ctk/action.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ inputs:
1818
required: false
1919
type: string
2020
default: "cuda_nvcc,cuda_cudart,cuda_crt,libnvvm,cuda_nvrtc,cuda_profiler_api,cuda_cccl,libnvjitlink,libcufile"
21+
cuda-path:
22+
description: "where the CTK components will be installed to, relative to $PWD"
23+
required: false
24+
type: string
25+
default: "./cuda_toolkit"
2126

2227
runs:
2328
using: composite
@@ -159,18 +164,24 @@ runs:
159164
exit 1
160165
fi
161166
167+
- name: Move CTK to the specified location
168+
if: ${{ inputs.cuda-path != './cuda_toolkit' }}
169+
shell: bash --noprofile --norc -xeuo pipefail {0}
170+
run: |
171+
mv ./cuda_toolkit ${{ inputs.cuda-path }}
172+
162173
- name: Set output environment variables
163174
shell: bash --noprofile --norc -xeuo pipefail {0}
164175
run: |
165176
# mimics actual CTK installation
166177
if [[ "${{ inputs.host-platform }}" == linux* ]]; then
167-
CUDA_PATH=$(realpath "./cuda_toolkit")
168-
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:${CUDA_PATH}/lib" >> $GITHUB_ENV
178+
CUDA_PATH=$(realpath "${{ inputs.cuda-path }}")
179+
echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib:${LD_LIBRARY_PATH:-}" >> $GITHUB_ENV
169180
elif [[ "${{ inputs.host-platform }}" == win* ]]; then
170181
function normpath() {
171182
echo "$(echo $(cygpath -w $1) | sed 's/\\/\\\\/g')"
172183
}
173-
CUDA_PATH=$(normpath $(realpath "./cuda_toolkit"))
184+
CUDA_PATH=$(normpath $(realpath "${{ inputs.cuda-path }}"))
174185
echo "$(normpath ${CUDA_PATH}/bin)" >> $GITHUB_PATH
175186
fi
176187
echo "CUDA_PATH=${CUDA_PATH}" >> $GITHUB_ENV

.github/workflows/build-wheel.yml

Lines changed: 112 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
cuda-version:
1212
required: true
1313
type: string
14+
prev-cuda-version:
15+
required: true
16+
type: string
1417

1518
defaults:
1619
run:
@@ -109,45 +112,67 @@ jobs:
109112
path: cuda_pathfinder/*.whl
110113
if-no-files-found: error
111114

115+
- name: Set up mini CTK
116+
uses: ./.github/actions/fetch_ctk
117+
continue-on-error: false
118+
with:
119+
host-platform: ${{ inputs.host-platform }}
120+
cuda-version: ${{ inputs.cuda-version }}
121+
122+
# TODO: this currently builds against the public cuda.bindings wheel. Consider
123+
# building against the wheel from main instead (the below step).
112124
- name: Build cuda.core wheel
113125
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
114126
with:
115127
package-dir: ./cuda_core/
116128
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
117-
118-
- name: List the cuda.core artifacts directory
129+
env:
130+
CIBW_BUILD: ${{ env.CIBW_BUILD }}
131+
CIBW_ENVIRONMENT: >
132+
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_CUDA_MAJOR }}
133+
# CIBW mounts the host filesystem under /host
134+
CIBW_ENVIRONMENT_LINUX: >
135+
CUDA_PATH=/host/${{ env.CUDA_PATH }}
136+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
137+
CIBW_ENVIRONMENT_WINDOWS: >
138+
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
139+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
140+
141+
- name: List the cuda.core artifacts directory and rename
119142
run: |
120143
if [[ "${{ inputs.host-platform }}" == win* ]]; then
121144
export CHOWN=chown
122145
else
123146
export CHOWN="sudo chown"
124147
fi
125148
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
126-
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
127-
128-
- name: Check cuda.core wheel
129-
run: |
130-
twine check --strict ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
131149
132-
- name: Upload cuda.core build artifacts
133-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
134-
with:
135-
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
136-
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
137-
if-no-files-found: error
150+
# Rename wheel to include CUDA version suffix
151+
for wheel in ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl; do
152+
if [[ -f "$wheel" ]]; then
153+
base_name=$(basename "$wheel" .whl)
154+
new_name="${base_name}.cu${BUILD_CUDA_MAJOR}.whl"
155+
mv "$wheel" "cu${BUILD_CUDA_MAJOR}/${new_name}"
156+
echo "Renamed wheel to: ${new_name}"
157+
fi
158+
done
138159
139-
- name: Set up mini CTK
140-
uses: ./.github/actions/fetch_ctk
141-
continue-on-error: false
142-
with:
143-
host-platform: ${{ inputs.host-platform }}
144-
cuda-version: ${{ inputs.cuda-version }}
160+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
145161
146162
- name: Build cuda.bindings wheel
147163
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
148164
with:
149165
package-dir: ./cuda_bindings/
150166
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
167+
env:
168+
CIBW_BUILD: ${{ env.CIBW_BUILD }}
169+
# CIBW mounts the host filesystem under /host
170+
CIBW_ENVIRONMENT_LINUX: >
171+
CUDA_PATH=/host/${{ env.CUDA_PATH }}
172+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
173+
CIBW_ENVIRONMENT_WINDOWS: >
174+
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
175+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
151176
152177
- name: List the cuda.bindings artifacts directory
153178
run: |
@@ -252,3 +277,71 @@ jobs:
252277
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}-tests
253278
path: ${{ env.CUDA_CORE_CYTHON_TESTS_DIR }}/test_*${{ env.PY_EXT_SUFFIX }}
254279
if-no-files-found: error
280+
281+
# Note: This overwrites CUDA_PATH etc
282+
- name: Set up mini CTK
283+
uses: ./.github/actions/fetch_ctk
284+
continue-on-error: false
285+
with:
286+
host-platform: ${{ inputs.host-platform }}
287+
cuda-version: ${{ inputs.prev-cuda-version }}
288+
cuda-path: "./cuda_toolkit_prev"
289+
290+
# TODO: this currently builds against the public cuda.bindings wheel. Consider
291+
# building against the wheel from the backport branch instead.
292+
- name: Build cuda.core wheel
293+
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
294+
with:
295+
package-dir: ./cuda_core/
296+
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
297+
env:
298+
CIBW_BUILD: ${{ env.CIBW_BUILD }}
299+
CIBW_ENVIRONMENT: >
300+
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_PREV_CUDA_MAJOR }}
301+
# CIBW mounts the host filesystem under /host
302+
CIBW_ENVIRONMENT_LINUX: >
303+
CUDA_PATH=/host/${{ env.CUDA_PATH }}
304+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
305+
CIBW_ENVIRONMENT_WINDOWS: >
306+
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
307+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
308+
309+
- name: List the cuda.core artifacts directory and rename
310+
run: |
311+
if [[ "${{ inputs.host-platform }}" == win* ]]; then
312+
export CHOWN=chown
313+
else
314+
export CHOWN="sudo chown"
315+
fi
316+
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
317+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
318+
319+
# Rename wheel to include CUDA version suffix
320+
for wheel in ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl; do
321+
if [[ -f "$wheel" ]]; then
322+
base_name=$(basename "$wheel" .whl)
323+
new_name="${base_name}.cu${BUILD_PREV_CUDA_MAJOR}.whl"
324+
mv "$wheel" "cu${BUILD_PREV_CUDA_MAJOR}/${new_name}"
325+
echo "Renamed wheel to: ${new_name}"
326+
fi
327+
done
328+
329+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
330+
331+
- name: Merge cuda.core wheels
332+
run: |
333+
python ci/tools/merge_cuda_core_wheels.py \
334+
"${{ env.CUDA_CORE_ARTIFACTS_DIR }}"/cu"${BUILD_CUDA_MAJOR}"/cuda_core*.whl \
335+
"${{ env.CUDA_CORE_ARTIFACTS_DIR }}"/cu"${BUILD_PREV_CUDA_MAJOR}"/cuda_core*.whl \
336+
--output-dir "${{ env.CUDA_CORE_ARTIFACTS_DIR }}"
337+
338+
- name: Check cuda.core wheel
339+
run: |
340+
twine check --strict ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
341+
342+
- name: Upload cuda.core build artifacts
343+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
344+
with:
345+
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
346+
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
347+
if-no-files-found: error

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,21 @@ jobs:
2121
runs-on: ubuntu-latest
2222
outputs:
2323
CUDA_BUILD_VER: ${{ steps.get-vars.outputs.cuda_build_ver }}
24+
CUDA_PREV_BUILD_VER: ${{ steps.get-vars.outputs.cuda_prev_build_ver }}
2425
steps:
2526
- name: Checkout repository
2627
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2728
with:
2829
fetch-depth: 0
29-
- name: Get CUDA build version
30+
- name: Get CUDA build versions
3031
id: get-vars
3132
run: |
3233
cuda_build_ver=$(jq -r .cuda.build.version ci/versions.json)
3334
echo "cuda_build_ver=$cuda_build_ver" >> $GITHUB_OUTPUT
3435
36+
cuda_prev_build_ver=$(jq -r .cuda.prev_build.version ci/versions.json)
37+
echo "cuda_prev_build_ver=$cuda_prev_build_ver" >> $GITHUB_OUTPUT
38+
3539
# WARNING: make sure all of the build jobs are in sync
3640
build-linux-64:
3741
needs:
@@ -48,6 +52,7 @@ jobs:
4852
with:
4953
host-platform: ${{ matrix.host-platform }}
5054
cuda-version: ${{ needs.ci-vars.outputs.CUDA_BUILD_VER }}
55+
prev-cuda-version: ${{ needs.ci-vars.outputs.CUDA_PREV_BUILD_VER }}
5156

5257
# WARNING: make sure all of the build jobs are in sync
5358
build-linux-aarch64:
@@ -65,6 +70,7 @@ jobs:
6570
with:
6671
host-platform: ${{ matrix.host-platform }}
6772
cuda-version: ${{ needs.ci-vars.outputs.CUDA_BUILD_VER }}
73+
prev-cuda-version: ${{ needs.ci-vars.outputs.CUDA_PREV_BUILD_VER }}
6874

6975
# WARNING: make sure all of the build jobs are in sync
7076
build-windows:
@@ -82,6 +88,7 @@ jobs:
8288
with:
8389
host-platform: ${{ matrix.host-platform }}
8490
cuda-version: ${{ needs.ci-vars.outputs.CUDA_BUILD_VER }}
91+
prev-cuda-version: ${{ needs.ci-vars.outputs.CUDA_PREV_BUILD_VER }}
8592

8693
# WARNING: make sure both Linux test jobs are in sync
8794
test-linux-64:

ci/tools/env-vars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ if [[ "${1}" == "build" ]]; then
4141
# platform is handled by the default value of platform (`auto`) in cibuildwheel
4242
# here we only need to specify the python version we want
4343
echo "CIBW_BUILD=cp${PYTHON_VERSION_FORMATTED}-*" >> $GITHUB_ENV
44+
BUILD_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${CUDA_VER})"
45+
echo "BUILD_CUDA_MAJOR=${BUILD_CUDA_MAJOR}" >> $GITHUB_ENV
46+
echo "BUILD_PREV_CUDA_MAJOR=$((${BUILD_CUDA_MAJOR} - 1))" >> $GITHUB_ENV
4447
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${CUDA_VER}-${HOST_PLATFORM}"
4548
elif [[ "${1}" == "test" ]]; then
4649
BUILD_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${BUILD_CUDA_VER})"

ci/versions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"cuda": {
33
"build": {
44
"version": "13.0.1"
5+
},
6+
"prev_build": {
7+
"version": "12.9.1"
58
}
69
}
710
}

cuda_bindings/pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,8 @@ environment-pass = ["CUDA_PATH", "CUDA_PYTHON_PARALLEL_LEVEL"]
6363

6464
[tool.cibuildwheel.linux]
6565
archs = "native"
66-
# CIBW mounts the host filesystem under /host
67-
environment-pass = ["CUDA_PATH"]
68-
environment = { CUDA_HOME = "/host/$CUDA_PATH" }
6966

7067
[tool.cibuildwheel.windows]
7168
archs = "AMD64"
7269
before-build = "pip install delvewheel"
7370
repair-wheel-command = "delvewheel repair --namespace-pkg cuda -w {dest_dir} {wheel}"
74-
environment = { CUDA_HOME = "$(cygpath -w $CUDA_PATH)" }

cuda_core/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ readme = { file = ["DESCRIPTION.rst"], content-type = "text/x-rst" }
7979
skip = "*-musllinux_*"
8080
enable = "cpython-freethreading"
8181
build-verbosity = 1
82-
environment-pass = ["CUDA_PYTHON_PARALLEL_LEVEL"]
82+
environment-pass = ["CUDA_PATH", "CUDA_PYTHON_PARALLEL_LEVEL"]
8383

8484
[tool.cibuildwheel.linux]
8585
archs = "native"

0 commit comments

Comments
 (0)