Skip to content

Commit b9e7679

Browse files
cosminccclaude
andcommitted
llama-cpp: host-side backend choice, release channels, fixes from testing
- Ask for the build on the Proxmox host with a whiptail menu (auto, cpu, vulkan, cuda, plus rocm/sycl/openvino on amd64) instead of inside the container, where the installer never has a terminal. Cancel exits; no terminal or a preset var_backend skips the menu - Match the Level Zero loader as libze1_*u24.04_amd64.deb: GitHub encodes the + in the asset URL as %2B, so the old pattern fell back to libze-dev - SYCL: write the persistent kernel cache commented out, it stopped models from loading on an Intel GPU - Add LLAMA_ARG_MODELS_DIR for router-mode model switching once LLAMA_ARG_HF_REPO is commented out - Release channels: bNNNN builds are now prereleases and stable vX.Y.Z releases carry only nightly-tag.txt. By default install the build the latest stable release names; GH_INCLUDE_PRERELEASE=1 follows the bNNNN builds. The channel is recorded in /opt/llama-cpp_data/.prerelease and updates keep it unless overridden; older installs count as nightly - Default model ggml-org/gemma-4-E2B-it-GGUF:Q4_0 (the previous default did not load on OpenVINO), still overridable with var_model_repo Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent f2707eb commit b9e7679

3 files changed

Lines changed: 75 additions & 31 deletions

File tree

‎ct/llama-cpp.sh‎

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@ var_gpu="${var_gpu:-yes}"
1919
var_unprivileged="${var_unprivileged:-1}"
2020
var_testurl="${var_testurl:-https://github.com/community-scripts/DevScripts/issues/2124}"
2121

22+
# Asked here because the installer runs under lxc-attach, where it can never
23+
# reach a terminal. Updates run inside the container and keep the recorded build.
24+
if [[ -z "${var_backend:-}" ]] && command -v pveversion >/dev/null 2>&1 && [[ -t 0 ]]; then
25+
LLAMA_BACKENDS=(
26+
"auto" "Vulkan if a GPU is passed through, else CPU"
27+
"cpu" "CPU only"
28+
"vulkan" "Vulkan (Intel, AMD and NVIDIA GPUs)"
29+
"cuda" "NVIDIA CUDA (12 or 13, from the host driver)"
30+
)
31+
if [[ "$(dpkg --print-architecture 2>/dev/null)" == "amd64" ]]; then
32+
LLAMA_BACKENDS+=(
33+
"rocm" "AMD ROCm"
34+
"sycl-fp16" "Intel GPU via oneAPI SYCL (FP16)"
35+
"sycl-fp32" "Intel GPU via oneAPI SYCL (FP32)"
36+
"openvino" "Intel CPU/GPU via OpenVINO"
37+
)
38+
fi
39+
var_backend=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "LLAMA.CPP BUILD" --default-item "auto" \
40+
--menu "Choose the llama.cpp build:" $((${#LLAMA_BACKENDS[@]} / 2 + 8)) 72 $((${#LLAMA_BACKENDS[@]} / 2)) \
41+
"${LLAMA_BACKENDS[@]}" 3>&1 1>&2 2>&3) || exit_script
42+
fi
43+
2244
export var_backend="${var_backend:-}"
2345
export var_model_repo="${var_model_repo:-}"
2446
export var_ctx_size="${var_ctx_size:-}"
@@ -41,8 +63,24 @@ function update_script() {
4163
exit
4264
fi
4365

44-
# Only the bNNNN tags carry the prebuilt binaries; other tags have no assets.
45-
if check_for_gh_release "llama-cpp" "ggml-org/llama.cpp" "" "" "b"; then
66+
# Follow the channel picked at install unless GH_INCLUDE_PRERELEASE is given
67+
# for this run: the bNNNN prerelease builds, or the build a stable vX.Y.Z
68+
# release names in its nightly-tag.txt (stable releases carry no binaries).
69+
# Installs that predate the record all tracked the bNNNN builds, and reading
70+
# them as stable would downgrade them.
71+
GH_INCLUDE_PRERELEASE="${GH_INCLUDE_PRERELEASE:-$(cat /opt/llama-cpp_data/.prerelease 2>/dev/null || echo 1)}"
72+
export GH_INCLUDE_PRERELEASE
73+
LLAMA_RELEASE=""
74+
if [[ "$GH_INCLUDE_PRERELEASE" == "1" ]]; then
75+
if check_for_gh_release "llama-cpp" "ggml-org/llama.cpp" "" "" "b"; then
76+
LLAMA_RELEASE="$CHECK_UPDATE_RELEASE"
77+
fi
78+
elif check_for_gh_release "llama-cpp-stable" "ggml-org/llama.cpp"; then
79+
USE_ORIGINAL_FILENAME=true fetch_and_deploy_gh_release "llama-cpp-stable" "ggml-org/llama.cpp" "singlefile" "$CHECK_UPDATE_RELEASE" "/opt/llama-cpp_data" "nightly-tag.txt"
80+
LLAMA_RELEASE="$(</opt/llama-cpp_data/nightly-tag.txt)"
81+
fi
82+
83+
if [[ -n "$LLAMA_RELEASE" ]]; then
4684
msg_info "Stopping Service"
4785
systemctl stop llama-cpp
4886
msg_ok "Stopped Service"
@@ -68,17 +106,17 @@ function update_script() {
68106
*) LLAMA_ASSET="llama-*-bin-ubuntu-${LLAMA_ARCH}.tar.gz" ;;
69107
esac
70108

71-
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "llama-cpp" "ggml-org/llama.cpp" "prebuild" "${CHECK_UPDATE_RELEASE}" "/opt/llama-cpp" "$LLAMA_ASSET" "b"
109+
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "llama-cpp" "ggml-org/llama.cpp" "prebuild" "$LLAMA_RELEASE" "/opt/llama-cpp" "$LLAMA_ASSET"
72110
# The wipe above also removed the CUDA runtime, so it always goes back in.
73111
if [[ -n "$LLAMA_CUDART_ASSET" ]]; then
74112
rm -f ~/.llama-cpp-cudart
75-
fetch_and_deploy_gh_release "llama-cpp-cudart" "ggml-org/llama.cpp" "prebuild" "${CHECK_UPDATE_RELEASE}" "/opt/llama-cpp" "$LLAMA_CUDART_ASSET" "b"
113+
fetch_and_deploy_gh_release "llama-cpp-cudart" "ggml-org/llama.cpp" "prebuild" "$LLAMA_RELEASE" "/opt/llama-cpp" "$LLAMA_CUDART_ASSET"
76114
fi
77115
chmod +x /opt/llama-cpp/llama-*
78116

79117
case "$LLAMA_BACKEND" in
80118
sycl-* | openvino)
81-
fetch_and_deploy_gh_release "level-zero" "oneapi-src/level-zero" "binary" "latest" "" "libze1_*+u24.04_amd64.deb" || true
119+
fetch_and_deploy_gh_release "level-zero" "oneapi-src/level-zero" "binary" "latest" "" "libze1_*u24.04_amd64.deb" || true
82120
if [[ -d /dev/dri ]]; then
83121
fetch_and_deploy_gh_release "intel-level-zero-gpu" "intel/compute-runtime" "binary" "latest" "" "libze-intel-gpu1_*_amd64.deb" || true
84122
fi
@@ -96,6 +134,8 @@ function update_script() {
96134
;;
97135
esac
98136

137+
echo "$GH_INCLUDE_PRERELEASE" >/opt/llama-cpp_data/.prerelease
138+
99139
msg_info "Starting Service"
100140
systemctl start llama-cpp
101141
msg_ok "Started Service"

‎install/llama-cpp-install.sh‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ setting_up_container
1313
network_check
1414
update_os
1515

16-
var_model_repo="${var_model_repo:-ggml-org/gemma-3-1b-it-GGUF}"
16+
var_model_repo="${var_model_repo:-ggml-org/gemma-4-E2B-it-GGUF:Q4_0}"
1717
var_port="${var_port:-8080}"
1818
var_ctx_size="${var_ctx_size:-4096}"
1919
var_offload_layers="${var_offload_layers:-}"
@@ -26,18 +26,6 @@ var_api_key="${var_api_key:-}"
2626
# rocm ubuntu-rocm-<ver>-x64 needs the matching ROCm (TheRock) runtime
2727
# sycl ubuntu-sycl-{fp16,fp32}-x64 Intel GPUs, needs oneAPI + Level Zero
2828
# openvino ubuntu-openvino-<ver>-x64 Intel CPU/GPU, OpenVINO runtime is bundled
29-
if [[ -z "${var_backend:-}" ]]; then
30-
LLAMA_CHOICE=$(prompt_select "Select the llama.cpp build:" 1 60 \
31-
"auto - Vulkan when a GPU is passed through, otherwise CPU" \
32-
"cpu - CPU only" \
33-
"vulkan - Vulkan (Intel, AMD and NVIDIA GPUs)" \
34-
"cuda - NVIDIA CUDA" \
35-
"rocm - AMD ROCm" \
36-
"sycl-fp16 - Intel GPU via oneAPI SYCL (FP16)" \
37-
"sycl-fp32 - Intel GPU via oneAPI SYCL (FP32)" \
38-
"openvino - Intel CPU/GPU via OpenVINO")
39-
var_backend="${LLAMA_CHOICE%% *}"
40-
fi
4129
var_backend="${var_backend:-auto}"
4230

4331
if [[ "$var_backend" == "auto" ]]; then
@@ -79,7 +67,7 @@ setup_hwaccel
7967
# SYCL and OpenVINO reach an Intel GPU through Level Zero. release.yml builds
8068
# SYCL against the loader from oneapi-src/level-zero, so use the same package.
8169
if [[ "$var_backend" == sycl-* || "$var_backend" == "openvino" ]]; then
82-
fetch_and_deploy_gh_release "level-zero" "oneapi-src/level-zero" "binary" "latest" "" "libze1_*+u24.04_amd64.deb"
70+
fetch_and_deploy_gh_release "level-zero" "oneapi-src/level-zero" "binary" "latest" "" "libze1_*u24.04_amd64.deb"
8371
if [[ -d /dev/dri ]]; then
8472
fetch_and_deploy_gh_release "intel-level-zero-gpu" "intel/compute-runtime" "binary" "latest" "" "libze-intel-gpu1_*_amd64.deb" || true
8573
fi
@@ -128,14 +116,21 @@ openvino) LLAMA_ASSET="llama-*-bin-ubuntu-openvino-*x64.tar.gz" ;;
128116
*) LLAMA_ASSET="llama-*-bin-ubuntu-${LLAMA_ARCH}.tar.gz" ;;
129117
esac
130118

131-
# Only the bNNNN tags carry the prebuilt binaries; other tags have no assets.
132-
fetch_and_deploy_gh_release "llama-cpp" "ggml-org/llama.cpp" "prebuild" "latest" "/opt/llama-cpp" "$LLAMA_ASSET" "b"
133-
LLAMA_RELEASE="$(cat ~/.llama-cpp)"
119+
# Only the bNNNN builds carry binaries, and upstream marks them prerelease. A
120+
# stable vX.Y.Z release ships just nightly-tag.txt, naming the build it was cut
121+
# from, so without GH_INCLUDE_PRERELEASE=1 that build is the one deployed.
122+
mkdir -p /opt/llama-cpp_data/models
123+
if [[ "${GH_INCLUDE_PRERELEASE:-0}" == "1" ]]; then
124+
fetch_and_deploy_gh_release "llama-cpp" "ggml-org/llama.cpp" "prebuild" "latest" "/opt/llama-cpp" "$LLAMA_ASSET" "b"
125+
LLAMA_RELEASE="$(cat ~/.llama-cpp)"
126+
else
127+
USE_ORIGINAL_FILENAME=true fetch_and_deploy_gh_release "llama-cpp-stable" "ggml-org/llama.cpp" "singlefile" "latest" "/opt/llama-cpp_data" "nightly-tag.txt"
128+
LLAMA_RELEASE="$(</opt/llama-cpp_data/nightly-tag.txt)"
129+
fetch_and_deploy_gh_release "llama-cpp" "ggml-org/llama.cpp" "prebuild" "$LLAMA_RELEASE" "/opt/llama-cpp" "$LLAMA_ASSET"
130+
fi
134131
if [[ -n "$LLAMA_CUDART_ASSET" ]]; then
135-
fetch_and_deploy_gh_release "llama-cpp-cudart" "ggml-org/llama.cpp" "prebuild" "$LLAMA_RELEASE" "/opt/llama-cpp" "$LLAMA_CUDART_ASSET" "b"
132+
fetch_and_deploy_gh_release "llama-cpp-cudart" "ggml-org/llama.cpp" "prebuild" "$LLAMA_RELEASE" "/opt/llama-cpp" "$LLAMA_CUDART_ASSET"
136133
fi
137-
138-
mkdir -p /opt/llama-cpp_data/models
139134
LLAMA_LIBPATH="/opt/llama-cpp"
140135

141136
# The ROCm build carries no ROCm libraries. release.yml builds it against AMD's
@@ -158,6 +153,7 @@ fi
158153
msg_info "Configuring llama.cpp"
159154
chmod +x /opt/llama-cpp/llama-*
160155
echo "$var_backend" >/opt/llama-cpp_data/.backend
156+
echo "${GH_INCLUDE_PRERELEASE:-0}" >/opt/llama-cpp_data/.prerelease
161157
if [[ -z "$var_offload_layers" ]]; then
162158
[[ "$var_backend" == "cpu" ]] && var_offload_layers=0 || var_offload_layers=999
163159
fi
@@ -169,6 +165,9 @@ LLAMA_ARG_PORT=${var_port}
169165
#LLAMA_ARG_MODEL=/opt/llama-cpp_data/models/your-model.gguf
170166
# ...or let llama-server pull one from Hugging Face on first start:
171167
LLAMA_ARG_HF_REPO=${var_model_repo}
168+
# Model switching: comment out LLAMA_ARG_HF_REPO (and LLAMA_ARG_MODEL) to serve
169+
# every model in this folder and pick one per request from the web UI or API:
170+
LLAMA_ARG_MODELS_DIR=/opt/llama-cpp_data/models
172171
173172
LLAMA_CACHE=/opt/llama-cpp_data/models
174173
LLAMA_ARG_CTX_SIZE=${var_ctx_size}
@@ -178,9 +177,10 @@ case "$var_backend" in
178177
sycl-*)
179178
cat <<EOF >>/opt/llama-cpp.env
180179
181-
# SYCL: cache JIT-compiled kernels across restarts; pick GPUs with the selector
182-
SYCL_CACHE_PERSISTENT=1
183-
SYCL_CACHE_DIR=/opt/llama-cpp_data/sycl-cache
180+
# SYCL: the persistent kernel cache speeds up restarts but can stop models
181+
# from loading on some Intel GPUs, so it is off by default
182+
#SYCL_CACHE_PERSISTENT=1
183+
#SYCL_CACHE_DIR=/opt/llama-cpp_data/sycl-cache
184184
#ONEAPI_DEVICE_SELECTOR=level_zero:0
185185
EOF
186186
;;

‎json/llama-cpp.json‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
"name": "var_model_repo",
5858
"label": "Model Repository",
5959
"type": "text",
60-
"default": "ggml-org/gemma-3-1b-it-GGUF",
61-
"help": "GGUF repo on HuggingFace, downloaded on first service start"
60+
"default": "ggml-org/gemma-4-E2B-it-GGUF:Q4_0",
61+
"help": "GGUF repo on HuggingFace, optionally with :QUANT, downloaded on first service start"
6262
},
6363
{
6464
"name": "var_ctx_size",
@@ -97,7 +97,7 @@
9797
],
9898
"notes": [
9999
{
100-
"text": "On first start llama-server downloads the model set in LLAMA_ARG_HF_REPO (default: ggml-org/gemma-3-1b-it-GGUF, roughly 800 MB) into /opt/llama-cpp_data/models, so the container is usable straight away. Swap it for any GGUF repo, or point LLAMA_ARG_MODEL at a local file, then restart.",
100+
"text": "On first start llama-server downloads the model set in LLAMA_ARG_HF_REPO (default: ggml-org/gemma-4-E2B-it-GGUF:Q4_0, roughly 3.5 GB with its vision projector) into /opt/llama-cpp_data/models, so the container is usable straight away. Choose another at install time with var_model_repo, or later swap it for any GGUF repo (repo or repo:QUANT), or point LLAMA_ARG_MODEL at a local file, then restart.",
101101
"type": "info"
102102
},
103103
{
@@ -111,6 +111,10 @@
111111
{
112112
"text": "RAM is the limiting factor: the model must fit alongside the KV cache. 8 GB comfortably runs models up to roughly 7B at Q4. Raise LLAMA_ARG_CTX_SIZE only if you have headroom.",
113113
"type": "info"
114+
},
115+
{
116+
"text": "By default the build named by the latest stable llama.cpp release (vX.Y.Z) is installed. Set GH_INCLUDE_PRERELEASE=1 to follow the nightly bNNNN builds instead. The choice is remembered in /opt/llama-cpp_data/.prerelease and used by updates; GH_INCLUDE_PRERELEASE=0 or 1 on an update run switches it.",
117+
"type": "info"
114118
}
115119
]
116120
}

0 commit comments

Comments
 (0)