-
Notifications
You must be signed in to change notification settings - Fork 0
220 lines (186 loc) · 8.51 KB
/
build-embedded.yml
File metadata and controls
220 lines (186 loc) · 8.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: Build Embedded ARM64 Binaries
on:
workflow_dispatch:
inputs:
version:
description: "llama.cpp tag to build (e.g. b8502)"
required: true
default: "b8502"
profiles:
description: "Comma-separated profiles to build (or 'all')"
required: true
default: "all"
push:
tags:
- "llama-embedded-*"
# ──────────────────────────────────────────────────────────────────────────────
# Strategy:
#
# Cross-compiled on ubuntu-24.04-arm runners (no device needed):
# rpi5-cpu, rpi5-vulkan, rpi4-cpu, rk3588-cpu, rk3588-vulkan,
# a76-cpu, a76-vulkan, a72-cpu, armv8-cpu
#
# Native build required (CUDA — must run on actual Jetson):
# jetson-orin-cuda → self-hosted runner labeled: [self-hosted, jetson-orin]
# jetson-xavier-cuda → self-hosted runner labeled: [self-hosted, jetson-xavier]
#
# To register a Jetson as a self-hosted runner:
# https://docs.github.com/en/actions/hosting-your-own-runners
# ──────────────────────────────────────────────────────────────────────────────
jobs:
# ── Determine which profiles to build ──────────────────────────────────────
setup:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.parse.outputs.version }}
cpu_profiles: ${{ steps.parse.outputs.cpu_profiles }}
cuda_profiles: ${{ steps.parse.outputs.cuda_profiles }}
steps:
- name: Parse inputs
id: parse
run: |
VERSION="${{ github.event.inputs.version || 'b8502' }}"
# Strip 'llama-embedded-' prefix if triggered by tag
VERSION="${VERSION#llama-embedded-}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
PROFILES="${{ github.event.inputs.profiles || 'all' }}"
ALL_CPU="rpi5-cpu rpi5-vulkan rpi4-cpu rk3588-cpu rk3588-vulkan a76-cpu a76-vulkan a72-cpu armv8-cpu"
ALL_CUDA="jetson-orin-cuda jetson-xavier-cuda"
if [ "$PROFILES" = "all" ]; then
CPU_LIST="$ALL_CPU"
CUDA_LIST="$ALL_CUDA"
else
CPU_LIST=""
CUDA_LIST=""
IFS=',' read -ra REQ <<< "$PROFILES"
for p in "${REQ[@]}"; do
p="${p// /}"
if [[ " $ALL_CPU " == *" $p "* ]]; then
CPU_LIST="$CPU_LIST $p"
elif [[ " $ALL_CUDA " == *" $p "* ]]; then
CUDA_LIST="$CUDA_LIST $p"
fi
done
fi
# Convert to JSON arrays for matrix
CPU_JSON=$(echo "$CPU_LIST" | tr ' ' '\n' | grep -v '^$' | jq -Rc '[.]' | jq -sc 'add')
CUDA_JSON=$(echo "$CUDA_LIST" | tr ' ' '\n' | grep -v '^$' | jq -Rc '[.]' | jq -sc 'add')
echo "cpu_profiles=${CPU_JSON}" >> "$GITHUB_OUTPUT"
echo "cuda_profiles=${CUDA_JSON}" >> "$GITHUB_OUTPUT"
echo "Building CPU profiles: $CPU_LIST"
echo "Building CUDA profiles: $CUDA_LIST"
# ── CPU / Vulkan builds (cross-compiled on GitHub-hosted ARM runners) ───────
build-cpu:
needs: setup
if: ${{ needs.setup.outputs.cpu_profiles != '[]' }}
runs-on: ubuntu-24.04-arm # GitHub-hosted ARM64 runner
strategy:
fail-fast: false
matrix:
profile: ${{ fromJson(needs.setup.outputs.cpu_profiles) }}
steps:
- name: Checkout build scripts
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
build-essential cmake git \
libvulkan-dev vulkan-tools glslc \
pkg-config
- name: Build ${{ matrix.profile }}
run: |
chmod +x ./scripts/build-embedded.sh
OUTPUT_DIR=./dist ./scripts/build-embedded.sh \
"${{ needs.setup.outputs.version }}" \
"${{ matrix.profile }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: llama-server-${{ needs.setup.outputs.version }}-${{ matrix.profile }}
path: dist/*.tar.gz
retention-days: 30
# ── CUDA builds (native Jetson — requires self-hosted runners) ─────────────
build-jetson-orin:
needs: setup
if: ${{ contains(fromJson(needs.setup.outputs.cuda_profiles), 'jetson-orin-cuda') }}
# Self-hosted Jetson Orin runner with JetPack 6 / CUDA 12
runs-on: [self-hosted, jetson-orin]
steps:
- name: Checkout build scripts
uses: actions/checkout@v4
- name: Install cmake (if needed)
run: |
cmake --version || sudo apt-get install -y cmake
- name: Build jetson-orin-cuda
run: |
chmod +x ./scripts/build-embedded.sh
OUTPUT_DIR=./dist ./scripts/build-embedded.sh \
"${{ needs.setup.outputs.version }}" \
jetson-orin-cuda
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: llama-server-${{ needs.setup.outputs.version }}-jetson-orin-cuda
path: dist/*.tar.gz
retention-days: 30
build-jetson-xavier:
needs: setup
if: ${{ contains(fromJson(needs.setup.outputs.cuda_profiles), 'jetson-xavier-cuda') }}
# Self-hosted Jetson Xavier runner with JetPack 5 / CUDA 11
runs-on: [self-hosted, jetson-xavier]
steps:
- name: Checkout build scripts
uses: actions/checkout@v4
- name: Build jetson-xavier-cuda
run: |
chmod +x ./scripts/build-embedded.sh
OUTPUT_DIR=./dist ./scripts/build-embedded.sh \
"${{ needs.setup.outputs.version }}" \
jetson-xavier-cuda
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: llama-server-${{ needs.setup.outputs.version }}-jetson-xavier-cuda
path: dist/*.tar.gz
retention-days: 30
# ── Collect all artifacts and create a release ──────────────────────────────
release:
needs: [setup, build-cpu, build-jetson-orin, build-jetson-xavier]
if: always() && (needs.build-cpu.result == 'success' || needs.build-jetson-orin.result == 'success' || needs.build-jetson-xavier.result == 'success')
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts
merge-multiple: true
- name: List built artifacts
run: |
echo "Built artifacts:"
find all-artifacts -name "*.tar.gz" | sort
- name: Create GitHub Release (on tag push)
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: all-artifacts/**/*.tar.gz
tag_name: ${{ github.ref_name }}
name: "llama-server embedded ${{ needs.setup.outputs.version }}"
body: |
## Embedded ARM64 llama-server builds
Based on llama.cpp **${{ needs.setup.outputs.version }}**
All builds use device-specific `-mcpu` flags to avoid SVE instructions
(`cntb`, etc.) that cause SIGILL on Cortex-A72/A76/A78AE CPUs.
| Artifact | Device | Accel | CPU Flags |
|---|---|---|---|
| `linux-arm64-jetson-orin-cuda-12` | Jetson Orin Nano/NX/AGX | CUDA 12 | `-mcpu=cortex-a78ae` |
| `linux-arm64-jetson-xavier-cuda-11` | Jetson Xavier NX/AGX | CUDA 11 | `-mcpu=carmel` |
| `linux-arm64-rpi5-vulkan` | Raspberry Pi 5 | Vulkan | `-mcpu=cortex-a76` |
| `linux-arm64-rpi5-cpu` | Raspberry Pi 5 | CPU | `-mcpu=cortex-a76` |
| `linux-arm64-rpi4-cpu` | Raspberry Pi 4 | CPU | `-mcpu=cortex-a72` |
| `linux-arm64-rk3588-vulkan` | Rockchip RK3588 | Vulkan | `-mcpu=cortex-a76` |
| `linux-arm64-rk3588-cpu` | Rockchare RK3588 | CPU | `-mcpu=cortex-a76` |
| `linux-arm64-a76-vulkan` | Generic A76 (OPi5, Rock 5B) | Vulkan | `-mcpu=cortex-a76` |
| `linux-arm64-a76-cpu` | Generic Cortex-A76 | CPU | `-mcpu=cortex-a76` |
| `linux-arm64-a72-cpu` | Generic Cortex-A72 | CPU | `-mcpu=cortex-a72` |
| `linux-arm64-armv8-cpu` | Generic ARMv8-A | CPU | `-march=armv8-a` |