Skip to content

Commit 118b8ea

Browse files
committed
test(ci): build CUDA 13 wheels
1 parent aab31f3 commit 118b8ea

1 file changed

Lines changed: 145 additions & 0 deletions

File tree

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Test CUDA 13 Wheels
2+
3+
on:
4+
push:
5+
branches:
6+
- test/cuda-13-wheels-build
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
name: Build CUDA ${{ matrix.cuda }} wheel on ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os:
20+
- ubuntu-22.04
21+
- windows-2022
22+
cuda:
23+
- 13.0.2
24+
- 13.2.1
25+
defaults:
26+
run:
27+
shell: pwsh
28+
env:
29+
CUDAVER: ${{ matrix.cuda }}
30+
31+
steps:
32+
- name: Set up MSVC
33+
if: runner.os == 'Windows'
34+
uses: ilammy/msvc-dev-cmd@v1
35+
with:
36+
arch: x64
37+
38+
- uses: actions/checkout@v4
39+
with:
40+
submodules: recursive
41+
42+
- uses: actions/setup-python@v5
43+
with:
44+
python-version: "3.9"
45+
cache: pip
46+
47+
- name: Setup Mamba
48+
uses: conda-incubator/setup-miniconda@v3.1.0
49+
with:
50+
activate-environment: llamacpp
51+
python-version: "3.9"
52+
miniforge-version: latest
53+
add-pip-as-python-dependency: true
54+
auto-activate-base: false
55+
56+
- name: Install dependencies
57+
env:
58+
MAMBA_DOWNLOAD_FAILFAST: "0"
59+
MAMBA_NO_LOW_SPEED_LIMIT: "1"
60+
run: |
61+
$cudaVersion = $env:CUDAVER
62+
$cudaChannel = "nvidia/label/cuda-$cudaVersion"
63+
if ($IsLinux) {
64+
mamba install -y --channel-priority flexible --override-channels -c $cudaChannel "${cudaChannel}::cuda-toolkit=$cudaVersion" "${cudaChannel}::cuda-nvcc_linux-64" "${cudaChannel}::cuda-cccl" "${cudaChannel}::cuda-cudart" "${cudaChannel}::cuda-cudart-dev"
65+
} elseif ($IsWindows) {
66+
mamba install -y --channel-priority flexible --override-channels -c $cudaChannel "${cudaChannel}::cuda-toolkit=$cudaVersion" "${cudaChannel}::cuda-nvcc_win-64" "${cudaChannel}::cuda-cccl" "${cudaChannel}::cuda-cudart" "${cudaChannel}::cuda-cudart-dev"
67+
} else {
68+
throw 'Unsupported CUDA wheel build platform'
69+
}
70+
if ($LASTEXITCODE -ne 0) {
71+
exit $LASTEXITCODE
72+
}
73+
if ($IsWindows) {
74+
python -m pip install build wheel ninja
75+
} else {
76+
python -m pip install build wheel
77+
}
78+
79+
- name: Build wheel
80+
run: |
81+
$pathSeparator = if ($IsWindows) { ';' } else { ':' }
82+
if ($IsWindows) {
83+
$cudaRoot = Join-Path $env:CONDA_PREFIX 'Library'
84+
} elseif (Test-Path (Join-Path $env:CONDA_PREFIX 'targets/x86_64-linux/include/cuda_runtime.h')) {
85+
$cudaRoot = Join-Path $env:CONDA_PREFIX 'targets/x86_64-linux'
86+
} else {
87+
$cudaRoot = $env:CONDA_PREFIX
88+
}
89+
90+
$env:CUDA_PATH = $cudaRoot
91+
$env:CUDA_HOME = $cudaRoot
92+
$env:CUDAToolkit_ROOT = $cudaRoot
93+
$env:CUDA_TOOLKIT_ROOT_DIR = $cudaRoot
94+
$cudaHostCompilerArg = ''
95+
$cudaRootCmake = $cudaRoot.Replace('\', '/')
96+
$env:CMAKE_ARGS = "-DCUDAToolkit_ROOT=$cudaRootCmake -DCUDA_TOOLKIT_ROOT_DIR=$cudaRootCmake"
97+
if ($IsLinux) {
98+
if (Test-Path '/usr/bin/g++-12') {
99+
$env:CC = '/usr/bin/gcc-12'
100+
$env:CXX = '/usr/bin/g++-12'
101+
$env:CUDAHOSTCXX = '/usr/bin/g++-12'
102+
$cudaHostCompilerArg = " -DCMAKE_CUDA_HOST_COMPILER=$env:CUDAHOSTCXX"
103+
}
104+
$env:CMAKE_ARGS = "-DCUDAToolkit_ROOT=$cudaRoot -DCUDA_TOOLKIT_ROOT_DIR=$cudaRoot$cudaHostCompilerArg"
105+
$env:CPATH = "$cudaRoot/include$pathSeparator$env:CPATH"
106+
$env:CPLUS_INCLUDE_PATH = "$cudaRoot/include$pathSeparator$env:CPLUS_INCLUDE_PATH"
107+
$env:LIBRARY_PATH = "$cudaRoot/lib$pathSeparator$env:CONDA_PREFIX/lib$pathSeparator$env:LIBRARY_PATH"
108+
$env:LD_LIBRARY_PATH = "$cudaRoot/lib$pathSeparator$env:CONDA_PREFIX/lib$pathSeparator$env:LD_LIBRARY_PATH"
109+
} elseif ($IsWindows) {
110+
$ninjaPath = ((Get-Command ninja -ErrorAction Stop).Source).Replace('\', '/')
111+
$env:CMAKE_GENERATOR = 'Ninja'
112+
$env:CMAKE_MAKE_PROGRAM = $ninjaPath
113+
$env:PATH = "$(Join-Path $cudaRoot 'bin')$pathSeparator$env:PATH"
114+
}
115+
116+
if ($IsWindows) {
117+
$nvccCandidates = @(
118+
(Join-Path $cudaRoot 'bin\nvcc.exe'),
119+
(Join-Path $env:CONDA_PREFIX 'Library\bin\nvcc.exe'),
120+
(Join-Path $env:CONDA_PREFIX 'bin\nvcc.exe')
121+
)
122+
} else {
123+
$nvccCandidates = @(
124+
(Join-Path $env:CONDA_PREFIX 'bin/nvcc'),
125+
(Join-Path $env:CONDA_PREFIX 'targets/x86_64-linux/bin/nvcc')
126+
)
127+
}
128+
$nvccPath = $nvccCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
129+
if (-not $nvccPath) {
130+
throw 'Failed to find nvcc in the conda environment'
131+
}
132+
$env:CUDACXX = $nvccPath
133+
$env:PATH = "$(Split-Path $nvccPath)$pathSeparator$env:PATH"
134+
if ($IsWindows) {
135+
$nvccPathCmake = $nvccPath.Replace('\', '/')
136+
$env:CUDACXX = $nvccPathCmake
137+
$env:CMAKE_ARGS = "-DCMAKE_CUDA_COMPILER=$nvccPathCmake -DCMAKE_CUDA_COMPILER_ARG1=-allow-unsupported-compiler -DCMAKE_MAKE_PROGRAM=$env:CMAKE_MAKE_PROGRAM $env:CMAKE_ARGS"
138+
}
139+
140+
$env:VERBOSE = '1'
141+
$env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=ON -DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=75-real;80-real;86-real;89-real;90-real;90-virtual -DCMAKE_CUDA_FLAGS=-allow-unsupported-compiler -DCMAKE_CUDA_FLAGS_INIT=-allow-unsupported-compiler $env:CMAKE_ARGS"
142+
$env:CMAKE_ARGS = "$env:CMAKE_ARGS -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off"
143+
& $nvccPath --version
144+
python -m build --wheel
145+
Get-ChildItem dist | Select-Object Name, Length

0 commit comments

Comments
 (0)