Skip to content

Commit ddf8bac

Browse files
committed
fix(ci): repair Linux accelerator wheels
1 parent a72325b commit ddf8bac

4 files changed

Lines changed: 136 additions & 42 deletions

File tree

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

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

3-
on: workflow_dispatch
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: Release tag to upload wheel assets to
8+
required: false
9+
type: string
410

511
permissions:
612
contents: write
@@ -131,7 +137,9 @@ jobs:
131137
if ($IsWindows) {
132138
python -m pip install build wheel ninja
133139
} else {
134-
python -m pip install build wheel
140+
sudo apt-get update
141+
sudo apt-get install -y patchelf
142+
python -m pip install auditwheel build wheel
135143
}
136144
137145
- name: Build Wheel
@@ -169,6 +177,12 @@ jobs:
169177
$env:CPLUS_INCLUDE_PATH = "$cudaRoot/include$pathSeparator$env:CPLUS_INCLUDE_PATH"
170178
$env:LIBRARY_PATH = "$cudaRoot/lib$pathSeparator$env:CONDA_PREFIX/lib$pathSeparator$env:LIBRARY_PATH"
171179
$env:LD_LIBRARY_PATH = "$cudaRoot/lib$pathSeparator$env:CONDA_PREFIX/lib$pathSeparator$env:LD_LIBRARY_PATH"
180+
$cudaLibraryPaths = @(
181+
(Join-Path $cudaRoot 'lib'),
182+
(Join-Path $cudaRoot 'lib64'),
183+
(Join-Path $env:CONDA_PREFIX 'lib')
184+
) | Where-Object { Test-Path $_ }
185+
Write-Output "CUDA_LIBRARY_PATHS=$($cudaLibraryPaths -join ':')" >> $env:GITHUB_ENV
172186
} elseif ($IsWindows) {
173187
$ninjaPath = ((Get-Command ninja -ErrorAction Stop).Source).Replace('\', '/')
174188
$env:CMAKE_GENERATOR = 'Ninja'
@@ -218,15 +232,44 @@ jobs:
218232
# SM. This keeps the wheel under GitHub's 2 GiB release-asset limit.
219233
$env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=ON -DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=$cudaArchs -DCMAKE_CUDA_FLAGS=-allow-unsupported-compiler -DCMAKE_CUDA_FLAGS_INIT=-allow-unsupported-compiler $env:CMAKE_ARGS"
220234
$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off'
235+
if ($IsLinux) {
236+
$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_OPENMP=OFF'
237+
}
221238
python -m build --wheel
222239
# Publish tags that reflect the actual installed toolkit version.
223240
Write-Output "CUDA_VERSION=$cudaTagVersion" >> $env:GITHUB_ENV
224241
242+
- name: Repair Linux wheel
243+
if: runner.os == 'Linux'
244+
shell: bash
245+
run: |
246+
set -euxo pipefail
247+
mkdir -p wheelhouse
248+
export LD_LIBRARY_PATH="$PWD/llama_cpp/lib:${CUDA_LIBRARY_PATHS}:${LD_LIBRARY_PATH:-}"
249+
auditwheel_bin="${CONDA}/envs/llamacpp/bin/auditwheel"
250+
"${auditwheel_bin}" repair \
251+
--exclude libcuda.so \
252+
--exclude libcuda.so.1 \
253+
--exclude libcudart.so.11.0 \
254+
--exclude libcudart.so.12 \
255+
--exclude libcudart.so.13 \
256+
--exclude libcublas.so.11 \
257+
--exclude libcublas.so.12 \
258+
--exclude libcublas.so.13 \
259+
--exclude libcublasLt.so.11 \
260+
--exclude libcublasLt.so.12 \
261+
--exclude libcublasLt.so.13 \
262+
-w wheelhouse \
263+
dist/*.whl
264+
rm dist/*.whl
265+
cp wheelhouse/*.whl dist/
266+
"${auditwheel_bin}" show dist/*.whl
267+
225268
- uses: softprops/action-gh-release@v3
226-
if: startsWith(github.ref, 'refs/tags/')
269+
if: startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.release_tag != '')
227270
with:
228271
files: dist/*
229-
# Set tag_name to <tag>-cu<cuda_version>
230-
tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }}
272+
# Set tag_name to <tag>-cu<cuda_version>.
273+
tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }}-cu${{ env.CUDA_VERSION }}
231274
env:
232275
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build-wheels-rocm.yaml

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
name: Build Wheels (ROCm)
22

3-
on: workflow_dispatch
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: Release tag to upload wheel assets to
8+
required: false
9+
type: string
10+
amdgpu_targets:
11+
description: AMDGPU targets to compile into the Linux ROCm wheel
12+
required: false
13+
default: gfx908;gfx90a;gfx942;gfx1030;gfx1100;gfx1101;gfx1102;gfx1150;gfx1151;gfx1200;gfx1201
14+
windows_amdgpu_targets:
15+
description: AMDGPU targets to compile into the Windows HIP Radeon wheel
16+
required: false
17+
default: gfx1150;gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032
418

519
permissions:
620
contents: write
@@ -24,7 +38,7 @@ jobs:
2438
- name: Install system dependencies
2539
run: |
2640
apt-get update
27-
apt-get install -y --no-install-recommends git cmake lsb-release ninja-build
41+
apt-get install -y --no-install-recommends git cmake lsb-release ninja-build patchelf
2842
2943
- uses: actions/checkout@v6
3044
with:
@@ -37,9 +51,12 @@ jobs:
3751
- name: Install build dependencies
3852
run: |
3953
python -m pip install --upgrade pip
40-
python -m pip install build wheel
54+
python -m pip install auditwheel build wheel
4155
4256
- name: Build ROCm wheel
57+
env:
58+
MATRIX_AMDGPU_TARGETS: ${{ matrix.amdgpu_targets }}
59+
INPUT_AMDGPU_TARGETS: ${{ inputs.amdgpu_targets }}
4360
run: |
4461
export ROCM_PATH="${ROCM_PATH:-/opt/rocm}"
4562
export HIP_PATH="${HIP_PATH:-$ROCM_PATH}"
@@ -56,11 +73,38 @@ jobs:
5673
rocm_tag="$(hipconfig --version | sed -E 's/^([0-9]+)\.([0-9]+).*/\1\2/')"
5774
echo "ROCM_VERSION=$rocm_tag" >> "$GITHUB_ENV"
5875
59-
amdgpu_targets="${{ matrix.amdgpu_targets }}"
60-
export CMAKE_ARGS="-DGGML_HIP=on -DGGML_NATIVE=off -DGGML_AVX=off -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off -DAMDGPU_TARGETS=$amdgpu_targets -DCMAKE_HIP_ARCHITECTURES=$amdgpu_targets"
76+
amdgpu_targets="${INPUT_AMDGPU_TARGETS:-$MATRIX_AMDGPU_TARGETS}"
77+
export CMAKE_ARGS="-DGGML_HIP=on -DGGML_NATIVE=off -DGGML_OPENMP=OFF -DGGML_AVX=off -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off -DAMDGPU_TARGETS=$amdgpu_targets -DCMAKE_HIP_ARCHITECTURES=$amdgpu_targets"
6178
python -m build --wheel
79+
80+
- name: Repair Linux wheel
81+
run: |
82+
export ROCM_PATH="${ROCM_PATH:-/opt/rocm}"
83+
export LD_LIBRARY_PATH="$PWD/llama_cpp/lib:$ROCM_PATH/lib:$ROCM_PATH/lib64:${LD_LIBRARY_PATH:-}"
6284
mkdir -p wheelhouse
63-
cp dist/*.whl wheelhouse/
85+
python -m auditwheel repair \
86+
--exclude libamdhip64.so \
87+
--exclude libamdhip64.so.6 \
88+
--exclude libamdhip64.so.7 \
89+
--exclude libhiprtc.so \
90+
--exclude libhiprtc.so.6 \
91+
--exclude libhiprtc.so.7 \
92+
--exclude libhipblas.so \
93+
--exclude libhipblas.so.2 \
94+
--exclude libhipblas.so.3 \
95+
--exclude libhipblaslt.so \
96+
--exclude libhipblaslt.so.0 \
97+
--exclude libhipblaslt.so.1 \
98+
--exclude librocblas.so \
99+
--exclude librocblas.so.4 \
100+
--exclude librocblas.so.5 \
101+
--exclude libhsa-runtime64.so.1 \
102+
--exclude libhsakmt.so.1 \
103+
-w wheelhouse \
104+
dist/*.whl
105+
rm dist/*.whl
106+
cp wheelhouse/*.whl dist/
107+
python -m auditwheel show dist/*.whl
64108
65109
- uses: actions/upload-artifact@v7
66110
with:
@@ -139,11 +183,14 @@ jobs:
139183
& $clangPath.FullName --version
140184
141185
- name: Build HIP wheel
186+
env:
187+
MATRIX_AMDGPU_TARGETS: ${{ matrix.amdgpu_targets }}
188+
INPUT_AMDGPU_TARGETS: ${{ inputs.windows_amdgpu_targets }}
142189
run: |
143190
$ErrorActionPreference = "Stop"
144191
$hipPath = Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Split-Path | Split-Path
145192
$rocwmmaInclude = (Join-Path $PWD 'opt\rocm-7.2.1\include').Replace('\', '/')
146-
$amdgpuTargets = "${{ matrix.amdgpu_targets }}"
193+
$amdgpuTargets = if ($env:INPUT_AMDGPU_TARGETS) { $env:INPUT_AMDGPU_TARGETS } else { $env:MATRIX_AMDGPU_TARGETS }
147194
148195
$env:HIP_PATH = $hipPath
149196
$env:ROCM_PATH = $hipPath
@@ -198,7 +245,7 @@ jobs:
198245
release_rocm:
199246
name: Release ROCm
200247
needs: [build_wheels]
201-
if: startsWith(github.ref, 'refs/tags/')
248+
if: startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.release_tag != '')
202249
runs-on: ubuntu-latest
203250

204251
steps:
@@ -211,14 +258,14 @@ jobs:
211258
with:
212259
files: dist/*
213260
# Set release name to <tag>-rocm<rocm_version>.
214-
tag_name: ${{ github.ref_name }}-rocm72
261+
tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }}-rocm72
215262
env:
216263
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
217264

218265
release_hip:
219266
name: Release HIP
220267
needs: [build_wheels_windows_hip]
221-
if: startsWith(github.ref, 'refs/tags/')
268+
if: startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.release_tag != '')
222269
runs-on: ubuntu-latest
223270

224271
steps:
@@ -231,6 +278,6 @@ jobs:
231278
with:
232279
files: dist/*
233280
# Set release name to <tag>-hip-radeon.
234-
tag_name: ${{ github.ref_name }}-hip-radeon
281+
tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }}-hip-radeon
235282
env:
236283
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build-wheels-vulkan.yaml

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
name: Build Wheels (Vulkan)
22

3-
on: workflow_dispatch
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: Release tag to upload wheel assets to
8+
required: false
9+
type: string
410

511
permissions:
612
contents: write
713

814
env:
915
VULKAN_SDK_VERSION: "1.4.341.0"
10-
VULKAN_SDK_LINUX_SHA256: "ed66477d587a5587dc3601b1c2cdcc1fab5529c505f53a00171876cecd9b4fbe"
1116

1217
jobs:
1318
build_wheels:
@@ -40,23 +45,6 @@ jobs:
4045
python-version: ${{ matrix.pyver }}
4146
cache: "pip"
4247

43-
- name: Install Vulkan SDK
44-
if: runner.os == 'Linux'
45-
run: |
46-
curl -fL \
47-
"https://sdk.lunarg.com/sdk/download/${VULKAN_SDK_VERSION}/linux/vulkansdk-linux-x86_64-${VULKAN_SDK_VERSION}.tar.xz" \
48-
-o vulkan-sdk.tar.xz
49-
echo "${VULKAN_SDK_LINUX_SHA256} vulkan-sdk.tar.xz" | sha256sum -c -
50-
mkdir -p "$RUNNER_TEMP/vulkan-sdk"
51-
tar -xf vulkan-sdk.tar.xz -C "$RUNNER_TEMP/vulkan-sdk"
52-
source "$RUNNER_TEMP/vulkan-sdk/${VULKAN_SDK_VERSION}/setup-env.sh"
53-
{
54-
echo "VULKAN_SDK=$VULKAN_SDK"
55-
echo "LD_LIBRARY_PATH=$VULKAN_SDK/lib:${LD_LIBRARY_PATH:-}"
56-
} >> "$GITHUB_ENV"
57-
echo "$VULKAN_SDK/bin" >> "$GITHUB_PATH"
58-
"$VULKAN_SDK/bin/glslc" --version
59-
6048
- name: Install Vulkan SDK
6149
if: runner.os == 'Windows'
6250
shell: pwsh
@@ -71,6 +59,7 @@ jobs:
7159
& "$vulkanSdk\Bin\glslc.exe" --version
7260
7361
- name: Install build dependencies
62+
if: runner.os == 'Windows'
7463
run: |
7564
python -m pip install --upgrade pip
7665
python -m pip install build wheel
@@ -81,11 +70,24 @@ jobs:
8170

8271
- name: Build Vulkan wheel
8372
if: runner.os == 'Linux'
84-
run: |
85-
export CMAKE_ARGS="-DGGML_NATIVE=off -DGGML_METAL=OFF -DGGML_VULKAN=on"
86-
python -m build --wheel
87-
mkdir -p wheelhouse
88-
cp dist/*.whl wheelhouse/
73+
uses: pypa/cibuildwheel@v3.4.1
74+
env:
75+
CIBW_BUILD: "cp38-manylinux_*"
76+
CIBW_ARCHS: "auto64"
77+
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014"
78+
CIBW_BEFORE_ALL_LINUX: >
79+
yum install -y xz &&
80+
curl -L https://micro.mamba.pm/api/micromamba/linux-64/latest -o /tmp/micromamba.tar.bz2 &&
81+
mkdir -p /tmp/micromamba &&
82+
tar -xjf /tmp/micromamba.tar.bz2 -C /tmp/micromamba bin/micromamba &&
83+
/tmp/micromamba/bin/micromamba create -y -p /opt/vulkan -c conda-forge shaderc vulkan-headers libvulkan-loader &&
84+
/opt/vulkan/bin/glslc --version
85+
CIBW_ENVIRONMENT_LINUX: >
86+
CMAKE_ARGS="-DGGML_NATIVE=off -DGGML_METAL=OFF -DGGML_OPENMP=OFF -DGGML_VULKAN=on -DVulkan_INCLUDE_DIR=/opt/vulkan/include -DVulkan_LIBRARY=/opt/vulkan/lib/libvulkan.so -DVulkan_GLSLC_EXECUTABLE=/opt/vulkan/bin/glslc"
87+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "LD_LIBRARY_PATH=/project/llama_cpp/lib:/opt/vulkan/lib auditwheel repair --exclude libvulkan.so.1 -w {dest_dir} {wheel}"
88+
with:
89+
package-dir: .
90+
output-dir: wheelhouse
8991

9092
- name: Build Vulkan wheel
9193
if: runner.os == 'Windows'
@@ -105,7 +107,7 @@ jobs:
105107
release:
106108
name: Release
107109
needs: [build_wheels]
108-
if: startsWith(github.ref, 'refs/tags/')
110+
if: startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.release_tag != '')
109111
runs-on: ubuntu-latest
110112

111113
steps:
@@ -118,6 +120,6 @@ jobs:
118120
with:
119121
files: dist/*
120122
# Set release name to <tag>-vulkan.
121-
tag_name: ${{ github.ref_name }}-vulkan
123+
tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }}-vulkan
122124
env:
123125
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
- fix(ci): Repair Linux accelerator wheels for manylinux publishing
11+
1012
## [0.3.28]
1113

1214
- feat(example): align server MTP support with llama.cpp by @abetlen in #2283

0 commit comments

Comments
 (0)