Skip to content

Commit 010d7bb

Browse files
committed
test(ci): build CUDA 11.8 wheels
1 parent ad4f275 commit 010d7bb

1 file changed

Lines changed: 136 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)