Skip to content

Commit ce661ad

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

File tree

7 files changed

+143
-28
lines changed

7 files changed

+143
-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: 114 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,68 @@ 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+
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
138160
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 }}
161+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
145162
146163
- name: Build cuda.bindings wheel
147164
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
148165
with:
149166
package-dir: ./cuda_bindings/
150167
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
168+
env:
169+
CIBW_BUILD: ${{ env.CIBW_BUILD }}
170+
# CIBW mounts the host filesystem under /host
171+
CIBW_ENVIRONMENT_LINUX: >
172+
CUDA_PATH=/host/${{ env.CUDA_PATH }}
173+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
174+
CIBW_ENVIRONMENT_WINDOWS: >
175+
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
176+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
151177
152178
- name: List the cuda.bindings artifacts directory
153179
run: |
@@ -252,3 +278,72 @@ jobs:
252278
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}-tests
253279
path: ${{ env.CUDA_CORE_CYTHON_TESTS_DIR }}/test_*${{ env.PY_EXT_SUFFIX }}
254280
if-no-files-found: error
281+
282+
# Note: This overwrites CUDA_PATH etc
283+
- name: Set up mini CTK
284+
uses: ./.github/actions/fetch_ctk
285+
continue-on-error: false
286+
with:
287+
host-platform: ${{ inputs.host-platform }}
288+
cuda-version: ${{ inputs.prev-cuda-version }}
289+
cuda-path: "./cuda_toolkit_prev"
290+
291+
# TODO: this currently builds against the public cuda.bindings wheel. Consider
292+
# building against the wheel from the backport branch instead.
293+
- name: Build cuda.core wheel
294+
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
295+
with:
296+
package-dir: ./cuda_core/
297+
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
298+
env:
299+
CIBW_BUILD: ${{ env.CIBW_BUILD }}
300+
CIBW_ENVIRONMENT: >
301+
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_PREV_CUDA_MAJOR }}
302+
# CIBW mounts the host filesystem under /host
303+
CIBW_ENVIRONMENT_LINUX: >
304+
CUDA_PATH=/host/${{ env.CUDA_PATH }}
305+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
306+
CIBW_ENVIRONMENT_WINDOWS: >
307+
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
308+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
309+
310+
- name: List the cuda.core artifacts directory and rename
311+
run: |
312+
if [[ "${{ inputs.host-platform }}" == win* ]]; then
313+
export CHOWN=chown
314+
else
315+
export CHOWN="sudo chown"
316+
fi
317+
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
318+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
319+
320+
# Rename wheel to include CUDA version suffix
321+
mkdir -p "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_PREV_CUDA_MAJOR}"
322+
for wheel in ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl; do
323+
if [[ -f "${wheel}" ]]; then
324+
base_name=$(basename "${wheel}" .whl)
325+
new_name="${base_name}.cu${BUILD_PREV_CUDA_MAJOR}.whl"
326+
mv "${wheel}" "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_PREV_CUDA_MAJOR}/${new_name}"
327+
echo "Renamed wheel to: ${new_name}"
328+
fi
329+
done
330+
331+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
332+
333+
- name: Merge cuda.core wheels
334+
run: |
335+
python ci/tools/merge_cuda_core_wheels.py \
336+
"${{ env.CUDA_CORE_ARTIFACTS_DIR }}"/cu"${BUILD_CUDA_MAJOR}"/cuda_core*.whl \
337+
"${{ env.CUDA_CORE_ARTIFACTS_DIR }}"/cu"${BUILD_PREV_CUDA_MAJOR}"/cuda_core*.whl \
338+
--output-dir "${{ env.CUDA_CORE_ARTIFACTS_DIR }}"
339+
340+
- name: Check cuda.core wheel
341+
run: |
342+
twine check --strict ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
343+
344+
- name: Upload cuda.core build artifacts
345+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
346+
with:
347+
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
348+
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
349+
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)