Skip to content

Commit 39e8f3a

Browse files
committed
chore: enhance build workflows with Vulkan support and update dependencies
- Updated build-sidecar.yml to use Vulkan as the default acceleration method for Linux and Windows. - Added installation steps for Vulkan SDK in both Linux and Windows environments. - Modified build-llama scripts to recognize Vulkan as a valid acceleration option. - Adjusted release.yml to reflect changes in acceleration settings and dependencies.
1 parent a5af87c commit 39e8f3a

4 files changed

Lines changed: 61 additions & 36 deletions

File tree

.github/workflows/build-sidecar.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ jobs:
2929
- os: macos-14 # Apple Silicon
3030
triple: mac-arm64
3131
accel: metal
32-
- os: macos-13 # Intel
33-
triple: mac-x64
34-
accel: cpu
3532
- os: ubuntu-22.04
3633
triple: linux-x64
37-
accel: cpu
34+
accel: vulkan
3835
- os: windows-2022
3936
triple: win-x64
40-
accel: cpu
37+
accel: vulkan
4138
runs-on: ${{ matrix.os }}
4239
name: ${{ matrix.triple }}
4340
defaults:
@@ -48,9 +45,21 @@ jobs:
4845
with:
4946
submodules: true
5047

51-
- name: Install cmake (Linux)
48+
- name: Install build deps (Linux)
5249
if: runner.os == 'Linux'
53-
run: sudo apt-get update -y && sudo apt-get install -y cmake build-essential
50+
run: sudo apt-get update -y && sudo apt-get install -y cmake build-essential libvulkan-dev
51+
52+
- name: Install Vulkan SDK (Windows)
53+
if: runner.os == 'Windows'
54+
shell: pwsh
55+
run: |
56+
$VK_VERSION = "1.4.313.0"
57+
$installer = "$env:RUNNER_TEMP\VulkanSDK.exe"
58+
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/$VK_VERSION/windows/VulkanSDK-$VK_VERSION-Installer.exe" -OutFile $installer
59+
Start-Process -FilePath $installer -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait
60+
$sdkPath = "C:\VulkanSDK\$VK_VERSION"
61+
Add-Content $env:GITHUB_ENV "VULKAN_SDK=$sdkPath"
62+
Add-Content $env:GITHUB_PATH "$sdkPath\Bin"
5463
5564
# cmake ships with macOS / windows runners already.
5665

.github/workflows/release.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,8 @@ defaults:
2020

2121
jobs:
2222
build-mac:
23-
strategy:
24-
fail-fast: false
25-
matrix:
26-
include:
27-
- runner: macos-14 # Apple Silicon
28-
triple: mac-arm64
29-
accel: metal
30-
arch_flag: --arm64
31-
- runner: macos-13 # Intel
32-
triple: mac-x64
33-
accel: cpu
34-
arch_flag: --x64
35-
runs-on: ${{ matrix.runner }}
36-
name: mac-${{ matrix.triple }}
23+
runs-on: macos-14
24+
name: mac-arm64
3725
steps:
3826
- uses: actions/checkout@v4
3927
with:
@@ -52,7 +40,7 @@ jobs:
5240
5341
- name: Build sidecar
5442
env:
55-
LLAMA_ACCEL: ${{ matrix.accel }}
43+
LLAMA_ACCEL: metal
5644
working-directory: minicpm-sidecar
5745
run: ./scripts/build-all.sh
5846

@@ -91,7 +79,7 @@ jobs:
9179
APPLE_ID: ${{ secrets.APPLE_ID }}
9280
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
9381
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
94-
run: npx electron-builder --mac ${{ matrix.arch_flag }} --publish never
82+
run: npx electron-builder --mac --arm64 --publish never
9583

9684
- name: Verify code signature
9785
if: ${{ secrets.CSC_LINK != '' }}
@@ -114,7 +102,7 @@ jobs:
114102
115103
- uses: actions/upload-artifact@v4
116104
with:
117-
name: mac-installer-${{ matrix.triple }}
105+
name: mac-installer-mac-arm64
118106
path: |
119107
clawd-on-desk/dist/*.dmg
120108
clawd-on-desk/dist/latest-mac.yml
@@ -134,14 +122,16 @@ jobs:
134122
python-version: "3.11"
135123

136124
- name: Install build deps
137-
run: sudo apt-get update -y && sudo apt-get install -y cmake build-essential
125+
run: sudo apt-get update -y && sudo apt-get install -y cmake build-essential libvulkan-dev
138126

139127
- name: Install uv
140128
run: |
141129
curl -LsSf https://astral.sh/uv/install.sh | sh
142130
echo "$HOME/.local/bin" >> $GITHUB_PATH
143131
144132
- name: Build sidecar
133+
env:
134+
LLAMA_ACCEL: vulkan
145135
working-directory: minicpm-sidecar
146136
run: ./scripts/build-all.sh
147137

@@ -178,13 +168,25 @@ jobs:
178168
with:
179169
python-version: "3.11"
180170

171+
- name: Install Vulkan SDK
172+
run: |
173+
$VK_VERSION = "1.4.313.0"
174+
$installer = "$env:RUNNER_TEMP\VulkanSDK.exe"
175+
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/$VK_VERSION/windows/VulkanSDK-$VK_VERSION-Installer.exe" -OutFile $installer
176+
Start-Process -FilePath $installer -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait
177+
$sdkPath = "C:\VulkanSDK\$VK_VERSION"
178+
Add-Content $env:GITHUB_ENV "VULKAN_SDK=$sdkPath"
179+
Add-Content $env:GITHUB_PATH "$sdkPath\Bin"
180+
181181
- name: Install uv
182182
run: |
183183
irm https://astral.sh/uv/install.ps1 | iex
184184
Add-Content $env:GITHUB_PATH "$env:USERPROFILE\.local\bin"
185185
186186
- name: Build llama-server
187187
working-directory: minicpm-sidecar
188+
env:
189+
LLAMA_ACCEL: vulkan
188190
run: ./scripts/build-llama.ps1
189191

190192
- name: Build gateway (PyInstaller)

minicpm-sidecar/scripts/build-llama.ps1

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# bin\win-x64\*.dll
66
#
77
# Honors:
8-
# $env:LLAMA_ACCEL = "cuda" | "cpu" (default: cpu)
8+
# $env:LLAMA_ACCEL = "vulkan" | "cuda" | "cpu" (default: vulkan)
99

1010
$ErrorActionPreference = "Stop"
1111

@@ -19,7 +19,7 @@ if (-not (Test-Path $src)) {
1919
Write-Error "$src not found. Run: git submodule update --init llama.cpp"
2020
}
2121

22-
$accel = if ($env:LLAMA_ACCEL) { $env:LLAMA_ACCEL } else { "cpu" }
22+
$accel = if ($env:LLAMA_ACCEL) { $env:LLAMA_ACCEL } else { "vulkan" }
2323
$target = "win-x64"
2424

2525
$flags = @(
@@ -30,9 +30,10 @@ $flags = @(
3030
"-DLLAMA_CURL=OFF"
3131
)
3232
switch ($accel) {
33-
"cuda" { $flags += "-DGGML_CUDA=ON" }
34-
"cpu" { $flags += "-DGGML_CUDA=OFF" }
35-
default { Write-Error "Unknown LLAMA_ACCEL=$accel (expected cuda|cpu)" }
33+
"vulkan" { $flags += "-DGGML_VULKAN=ON" }
34+
"cuda" { $flags += "-DGGML_CUDA=ON" }
35+
"cpu" { $flags += "-DGGML_VULKAN=OFF"; $flags += "-DGGML_CUDA=OFF" }
36+
default { Write-Error "Unknown LLAMA_ACCEL=$accel (expected vulkan|cuda|cpu)" }
3637
}
3738

3839
Write-Host "==> Target: $target Accel: $accel" -ForegroundColor Cyan
@@ -42,9 +43,15 @@ if (-not (Get-Command cmake -ErrorAction SilentlyContinue)) {
4243
Write-Error "cmake not found in PATH. Install via winget/choco or Visual Studio Build Tools."
4344
}
4445

46+
$jobs = if ($env:LLAMA_JOBS) { $env:LLAMA_JOBS } else {
47+
$ncpu = (Get-CimInstance Win32_Processor).NumberOfLogicalProcessors
48+
if ($env:CI -and $ncpu -gt 4) { 4 } else { $ncpu }
49+
}
50+
Write-Host "==> cmake build (-j$jobs)" -ForegroundColor Cyan
51+
4552
New-Item -ItemType Directory -Force -Path $build | Out-Null
4653
& cmake -S $src -B $build @flags
47-
& cmake --build $build --target llama-server --config Release -j
54+
& cmake --build $build --target llama-server --config Release -j $jobs
4855

4956
$server = $null
5057
foreach ($cand in @(

minicpm-sidecar/scripts/build-llama.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ case "$(uname -s)-$(uname -m)" in
3939
;;
4040
Linux-x86_64)
4141
TARGET="linux-x64"
42-
ACCEL="${LLAMA_ACCEL:-cpu}"
42+
ACCEL="${LLAMA_ACCEL:-vulkan}"
4343
;;
4444
Linux-aarch64)
4545
TARGET="linux-arm64"
@@ -63,14 +63,17 @@ case "$ACCEL" in
6363
metal)
6464
CMAKE_FLAGS+=( -DGGML_METAL=ON -DGGML_METAL_EMBED_LIBRARY=ON )
6565
;;
66+
vulkan)
67+
CMAKE_FLAGS+=( -DGGML_VULKAN=ON )
68+
;;
6669
cuda)
6770
CMAKE_FLAGS+=( -DGGML_CUDA=ON )
6871
;;
6972
cpu)
70-
CMAKE_FLAGS+=( -DGGML_METAL=OFF -DGGML_CUDA=OFF )
73+
CMAKE_FLAGS+=( -DGGML_METAL=OFF -DGGML_CUDA=OFF -DGGML_VULKAN=OFF )
7174
;;
7275
*)
73-
red "未知 LLAMA_ACCEL=$ACCEL(应为 metal/cuda/cpu)"
76+
red "未知 LLAMA_ACCEL=$ACCEL(应为 metal/vulkan/cuda/cpu)"
7477
exit 1
7578
;;
7679
esac
@@ -87,8 +90,12 @@ mkdir -p "$BUILD"
8790
cyan "==> cmake configure"
8891
cmake -S "$SRC" -B "$BUILD" "${CMAKE_FLAGS[@]}"
8992

90-
cyan "==> cmake build llama-server"
91-
cmake --build "$BUILD" --target llama-server --config Release -j
93+
JOBS="${LLAMA_JOBS:-$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)}"
94+
if [[ -n "${CI:-}" && "$JOBS" -gt 4 ]]; then
95+
JOBS=4
96+
fi
97+
cyan "==> cmake build llama-server (-j$JOBS)"
98+
cmake --build "$BUILD" --target llama-server --config Release -j"$JOBS"
9299

93100
# llama.cpp puts the binary somewhere predictable; try both layouts.
94101
SERVER=""

0 commit comments

Comments
 (0)