Skip to content

Commit ab7a9b0

Browse files
authored
feat(ci): add Vulkan wheel builds (abetlen#2251)
* feat(ci): add Vulkan wheel builds * docs: update changelog for Vulkan wheel builds * docs: add Vulkan wheel install instructions
1 parent 6e6c4e6 commit ab7a9b0

4 files changed

Lines changed: 135 additions & 1 deletion

File tree

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Build Wheels (Vulkan)
2+
3+
on: workflow_dispatch
4+
5+
permissions:
6+
contents: write
7+
8+
env:
9+
VULKAN_SDK_VERSION: "1.4.341.0"
10+
VULKAN_SDK_LINUX_SHA256: "ed66477d587a5587dc3601b1c2cdcc1fab5529c505f53a00171876cecd9b4fbe"
11+
12+
jobs:
13+
build_wheels:
14+
name: Build Vulkan wheel on ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- os: ubuntu-22.04
21+
pyver: "3.9"
22+
artifact: wheels-vulkan-ubuntu-22.04
23+
- os: windows-2022
24+
pyver: "3.9"
25+
artifact: wheels-vulkan-windows-2022
26+
27+
steps:
28+
- name: Set up MSVC
29+
if: runner.os == 'Windows'
30+
uses: ilammy/msvc-dev-cmd@v1
31+
with:
32+
arch: x64
33+
34+
- uses: actions/checkout@v4
35+
with:
36+
submodules: "recursive"
37+
38+
- uses: actions/setup-python@v6
39+
with:
40+
python-version: ${{ matrix.pyver }}
41+
cache: "pip"
42+
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+
60+
- name: Install Vulkan SDK
61+
if: runner.os == 'Windows'
62+
shell: pwsh
63+
run: |
64+
choco install vulkan-sdk --version="$env:VULKAN_SDK_VERSION" --no-progress -y
65+
$vulkanSdk = Join-Path 'C:\VulkanSDK' $env:VULKAN_SDK_VERSION
66+
if (-not (Test-Path $vulkanSdk)) {
67+
throw "Failed to find Vulkan SDK at $vulkanSdk"
68+
}
69+
"VULKAN_SDK=$vulkanSdk" >> $env:GITHUB_ENV
70+
"$vulkanSdk\Bin" >> $env:GITHUB_PATH
71+
& "$vulkanSdk\Bin\glslc.exe" --version
72+
73+
- name: Install build dependencies
74+
run: |
75+
python -m pip install --upgrade pip
76+
python -m pip install build wheel
77+
78+
- name: Install Windows build dependencies
79+
if: runner.os == 'Windows'
80+
run: python -m pip install ninja
81+
82+
- name: Build Vulkan wheel
83+
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/
89+
90+
- name: Build Vulkan wheel
91+
if: runner.os == 'Windows'
92+
shell: pwsh
93+
run: |
94+
$env:CMAKE_GENERATOR = 'Ninja'
95+
$env:CMAKE_ARGS = '-DGGML_NATIVE=off -DGGML_VULKAN=on'
96+
python -m build --wheel
97+
New-Item -ItemType Directory -Force wheelhouse | Out-Null
98+
Copy-Item dist/*.whl wheelhouse/
99+
100+
- uses: actions/upload-artifact@v7
101+
with:
102+
name: ${{ matrix.artifact }}
103+
path: ./wheelhouse/*.whl
104+
105+
release:
106+
name: Release
107+
needs: [build_wheels]
108+
if: startsWith(github.ref, 'refs/tags/')
109+
runs-on: ubuntu-latest
110+
111+
steps:
112+
- uses: actions/download-artifact@v4
113+
with:
114+
merge-multiple: true
115+
path: dist
116+
117+
- uses: softprops/action-gh-release@v2
118+
with:
119+
files: dist/*
120+
# Set release name to <tag>-vulkan.
121+
tag_name: ${{ github.ref_name }}-vulkan
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/generate-index-from-release.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Wheels Index
33
on:
44
# Trigger on new release
55
workflow_run:
6-
workflows: ["Release", "Build Wheels (CUDA)", "Build Wheels (Metal)"]
6+
workflows: ["Release", "Build Wheels (CUDA)", "Build Wheels (Metal)", "Build Wheels (Vulkan)"]
77
types:
88
- completed
99

@@ -46,6 +46,7 @@ jobs:
4646
./scripts/releases-to-pep-503.sh index/whl/cu124 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu124$'
4747
# ./scripts/releases-to-pep-503.sh index/whl/cu125 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu124$'
4848
# ./scripts/releases-to-pep-503.sh index/whl/cu126 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu124$'
49+
./scripts/releases-to-pep-503.sh index/whl/vulkan '^[v]?[0-9]+\.[0-9]+\.[0-9]+-vulkan$'
4950
./scripts/releases-to-pep-503.sh index/whl/metal '^[v]?[0-9]+\.[0-9]+\.[0-9]+-metal$'
5051
- name: Upload artifact
5152
uses: actions/upload-pages-artifact@v3

CHANGELOG.md

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

88
## [Unreleased]
99

10+
- feat(ci): add Vulkan wheel builds by @abetlen in #2251
1011
- fix: handle additional `from_pretrained` files in subfolders by @TNing in #2085
1112

1213
## [0.3.25]

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,15 @@ To install with Vulkan support, set the `GGML_VULKAN=on` environment variable be
196196
CMAKE_ARGS="-DGGML_VULKAN=on" pip install llama-cpp-python
197197
```
198198

199+
**Pre-built Wheel (New)**
200+
201+
It is also possible to install a pre-built wheel with Vulkan support for Linux or Windows:
202+
203+
```bash
204+
pip install llama-cpp-python \
205+
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/vulkan
206+
```
207+
199208
</details>
200209

201210
<details>

0 commit comments

Comments
 (0)