Skip to content

Commit 110e2d0

Browse files
committed
chore(ci): simplify Windows CUDA wheel workflow
1 parent 497e4a0 commit 110e2d0

1 file changed

Lines changed: 17 additions & 169 deletions

File tree

‎.github/workflows/build-wheels-cuda.yaml‎

Lines changed: 17 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,6 @@
11
name: Build Wheels (CUDA)
22

3-
on:
4-
workflow_dispatch:
5-
inputs:
6-
os:
7-
description: OS to build
8-
required: true
9-
default: all
10-
type: choice
11-
options:
12-
- all
13-
- ubuntu-22.04
14-
- windows-2022
15-
cuda:
16-
description: CUDA toolkit version to build
17-
required: true
18-
default: all
19-
type: choice
20-
options:
21-
- all
22-
- 12.1.1
23-
- 12.2.2
24-
- 12.3.2
25-
- 12.4.1
26-
- 12.5.1
27-
test_python:
28-
description: Python version to smoke-test
29-
required: true
30-
default: all
31-
type: choice
32-
options:
33-
- all
34-
- "3.9"
35-
- "3.10"
36-
- "3.11"
37-
- "3.12"
38-
- "3.13"
3+
on: workflow_dispatch
394

405
permissions:
416
contents: write
@@ -45,9 +10,7 @@ jobs:
4510
name: Define Build Matrix
4611
runs-on: ubuntu-22.04
4712
outputs:
48-
build_matrix: ${{ steps.set-matrix.outputs.build_matrix }}
49-
test_matrix: ${{ steps.set-matrix.outputs.test_matrix }}
50-
publish_matrix: ${{ steps.set-matrix.outputs.publish_matrix }}
13+
matrix: ${{ steps.set-matrix.outputs.matrix }}
5114
defaults:
5215
run:
5316
shell: pwsh
@@ -56,54 +19,24 @@ jobs:
5619
- name: Define Job Output
5720
id: set-matrix
5821
run: |
59-
$osInput = '${{ inputs.os }}'
60-
$cudaInput = '${{ inputs.cuda }}'
61-
$testPythonInput = '${{ inputs.test_python }}'
62-
63-
if ([string]::IsNullOrWhiteSpace($osInput) -or $osInput -eq 'all') {
64-
$os = @('ubuntu-22.04', 'windows-2022')
65-
} else {
66-
$os = @($osInput)
67-
}
68-
if ([string]::IsNullOrWhiteSpace($cudaInput) -or $cudaInput -eq 'all') {
69-
$cuda = @("12.1.1", "12.2.2", "12.3.2", "12.4.1", "12.5.1")
70-
} else {
71-
$cuda = @($cudaInput)
72-
}
73-
if ([string]::IsNullOrWhiteSpace($testPythonInput) -or $testPythonInput -eq 'all') {
74-
$testPython = @("3.9", "3.10", "3.11", "3.12", "3.13")
75-
} else {
76-
$testPython = @($testPythonInput)
77-
}
78-
79-
$buildMatrix = @{
80-
'os' = $os
22+
$matrix = @{
23+
'os' = @('ubuntu-22.04', 'windows-2022')
8124
# wheel.py-api = "py3" makes the CUDA wheel interpreter-agnostic,
8225
# so one builder per toolkit version is sufficient.
8326
'pyver' = @("3.9")
84-
'cuda' = $cuda
27+
'cuda' = @("12.1.1", "12.2.2", "12.3.2", "12.4.1", "12.5.1")
8528
'releasetag' = @("basic")
8629
}
87-
$testMatrix = @{
88-
'os' = $os
89-
'cuda' = $cuda
90-
'pyver' = $testPython
91-
}
92-
$publishMatrix = @{
93-
'cuda' = $cuda
94-
}
9530
96-
Write-Output ('build_matrix=' + (ConvertTo-Json $buildMatrix -Compress)) >> $env:GITHUB_OUTPUT
97-
Write-Output ('test_matrix=' + (ConvertTo-Json $testMatrix -Compress)) >> $env:GITHUB_OUTPUT
98-
Write-Output ('publish_matrix=' + (ConvertTo-Json $publishMatrix -Compress)) >> $env:GITHUB_OUTPUT
31+
$matrixOut = ConvertTo-Json $matrix -Compress
32+
Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT
9933
10034
build_wheels:
10135
name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }}
10236
needs: define_matrix
10337
runs-on: ${{ matrix.os }}
10438
strategy:
105-
fail-fast: false
106-
matrix: ${{ fromJSON(needs.define_matrix.outputs.build_matrix) }}
39+
matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }}
10740
defaults:
10841
run:
10942
shell: pwsh
@@ -144,49 +77,25 @@ jobs:
14477
$cudaVersion = $env:CUDAVER
14578
$cudaChannel = "nvidia/label/cuda-$cudaVersion"
14679
if ($IsLinux) {
147-
$nvccPackage = "${cudaChannel}::cuda-nvcc_linux-64"
148-
$cudaPackages = @("${cudaChannel}::cuda-toolkit=$cudaVersion", $nvccPackage)
80+
mamba install -y --channel-priority flexible --override-channels -c $cudaChannel "${cudaChannel}::cuda-toolkit=$cudaVersion" "${cudaChannel}::cuda-nvcc_linux-64" "${cudaChannel}::cuda-cudart" "${cudaChannel}::cuda-cudart-dev"
14981
} elseif ($IsWindows) {
150-
$nvccPackage = "${cudaChannel}::cuda-nvcc_win-64"
15182
if ($cudaVersion -like '12.5.*') {
152-
# The Windows 12.5 toolkit meta-package pulls conda compiler
153-
# activation scripts that can overflow cmd.exe's line limit after
154-
# MSVC is already initialized. Install the smaller pieces the
155-
# CUDA backend actually needs without pulling the compiler meta.
156-
$cudaPackages = @($nvccPackage, "${cudaChannel}::cuda-libraries-dev=$cudaVersion")
83+
# The Windows 12.5 toolkit meta-package pulls compiler activation
84+
# scripts that overflow cmd.exe after MSVC is already initialized.
85+
mamba install -y --channel-priority flexible --override-channels -c $cudaChannel "${cudaChannel}::cuda-nvcc_win-64" "${cudaChannel}::cuda-libraries-dev=$cudaVersion" "${cudaChannel}::cuda-cudart" "${cudaChannel}::cuda-cudart-dev"
15786
} else {
158-
$cudaPackages = @("${cudaChannel}::cuda-toolkit=$cudaVersion", $nvccPackage)
87+
mamba install -y --channel-priority flexible --override-channels -c $cudaChannel "${cudaChannel}::cuda-toolkit=$cudaVersion" "${cudaChannel}::cuda-nvcc_win-64" "${cudaChannel}::cuda-cudart" "${cudaChannel}::cuda-cudart-dev"
15988
}
16089
} else {
16190
throw 'Unsupported CUDA wheel build platform'
16291
}
163-
# Keep nvcc, cudart, and headers on the same NVIDIA label so the
164-
# detected toolkit version matches the published wheel tag.
165-
$mambaArgs = @(
166-
'install',
167-
'-y',
168-
'--channel-priority',
169-
'flexible',
170-
'--override-channels',
171-
'-c',
172-
$cudaChannel
173-
) + $cudaPackages + @(
174-
"${cudaChannel}::cuda-cudart",
175-
"${cudaChannel}::cuda-cudart-dev"
176-
)
177-
& mamba @mambaArgs
17892
if ($LASTEXITCODE -ne 0) {
17993
exit $LASTEXITCODE
18094
}
181-
python -m pip install build wheel ninja
182-
183-
- name: Show CUDA diagnostics
184-
run: |
185-
mamba list | Select-String 'cuda|nvidia|cudatoolkit'
18695
if ($IsWindows) {
187-
Get-ChildItem -Path $env:CONDA_PREFIX -Recurse -Filter nvcc.exe | Select-Object -First 10 -ExpandProperty FullName
96+
python -m pip install build wheel ninja
18897
} else {
189-
Get-ChildItem -Path $env:CONDA_PREFIX -Recurse -Filter nvcc | Select-Object -First 10 -ExpandProperty FullName
98+
python -m pip install build wheel
19099
}
191100
192101
- name: Build Wheel
@@ -264,71 +173,10 @@ jobs:
264173
# Publish tags that reflect the actual installed toolkit version.
265174
Write-Output "CUDA_VERSION=$cudaTagVersion" >> $env:GITHUB_ENV
266175
267-
- uses: actions/upload-artifact@v4
268-
with:
269-
name: cuda-wheel-${{ matrix.os }}-${{ matrix.cuda }}
270-
path: dist/*.whl
271-
272-
test_wheels:
273-
name: Test Wheel ${{ matrix.os }} ${{ matrix.cuda }} Python ${{ matrix.pyver }}
274-
needs: [define_matrix, build_wheels]
275-
runs-on: ${{ matrix.os }}
276-
strategy:
277-
fail-fast: false
278-
matrix: ${{ fromJSON(needs.define_matrix.outputs.test_matrix) }}
279-
defaults:
280-
run:
281-
shell: pwsh
282-
283-
steps:
284-
- uses: actions/setup-python@v5
285-
with:
286-
python-version: ${{ matrix.pyver }}
287-
288-
- uses: actions/download-artifact@v4
289-
with:
290-
name: cuda-wheel-${{ matrix.os }}-${{ matrix.cuda }}
291-
path: dist
292-
293-
- name: Test wheel installation
294-
run: |
295-
$wheel = (Get-ChildItem dist -Filter '*.whl' | Select-Object -First 1).FullName
296-
python -m pip install --upgrade pip
297-
python -m pip install $wheel
298-
python -m pip check
299-
# Avoid importing llama_cpp here: GitHub-hosted runners do not provide
300-
# NVIDIA drivers, so native CUDA library loading can fail independently
301-
# of Python-version wheel compatibility.
302-
python -c "from importlib.metadata import version; print(version('llama_cpp_python'))"
303-
304-
publish_wheels:
305-
name: Publish Wheels CUDA ${{ matrix.cuda }}
306-
needs: [define_matrix, test_wheels]
307-
if: startsWith(github.ref, 'refs/tags/')
308-
runs-on: ubuntu-22.04
309-
strategy:
310-
fail-fast: false
311-
matrix: ${{ fromJSON(needs.define_matrix.outputs.publish_matrix) }}
312-
defaults:
313-
run:
314-
shell: pwsh
315-
316-
steps:
317-
- uses: actions/download-artifact@v4
318-
with:
319-
pattern: cuda-wheel-*-${{ matrix.cuda }}
320-
path: dist
321-
merge-multiple: true
322-
323-
- name: Set CUDA release tag
324-
run: |
325-
$versionParts = "${{ matrix.cuda }}".Split('.')
326-
$cudaVersion = "$($versionParts[0])$($versionParts[1])"
327-
Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV
328-
329176
- uses: softprops/action-gh-release@v2
177+
if: startsWith(github.ref, 'refs/tags/')
330178
with:
331-
files: dist/*.whl
179+
files: dist/*
332180
# Set tag_name to <tag>-cu<cuda_version>
333181
tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }}
334182
env:

0 commit comments

Comments
 (0)