AI: Drop ROCm support from the llama.cpp install script

Only Vulkan and CPU (plus Intel SYCL) builds are installed now. Benchmarks
show Vulkan generally matches or beats the ROCm build for llama.cpp (except
some prompt-processing cases), while ROCm is far more complex to provision:
the prebuilt HIP backend needs a matching ROCm runtime, and consumer/iGPU
architectures such as gfx1150 additionally require HSA_OVERRIDE_GFX_VERSION
because rocBLAS ships no kernels for them. Vulkan drives NVIDIA, AMD, and
Intel GPUs on Linux with none of that setup, so auto-detection now selects
the Vulkan build for any supported GPU and the CPU build otherwise.
This commit is contained in:
Michael Mayer 2026-07-10 10:39:52 +02:00
parent fb6e17ee69
commit 79a3d36334

View file

@ -2,11 +2,12 @@
# Installs llama.cpp prebuilt Linux binaries from GitHub on AMD64 and ARM64. # Installs llama.cpp prebuilt Linux binaries from GitHub on AMD64 and ARM64.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-llamacpp.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-llamacpp.sh)
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-llamacpp.sh) -- --rocm /usr/local b9948 # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-llamacpp.sh) -- --vulkan /usr/local b9948
# #
# The accelerator is auto-detected by default (ROCm or Vulkan for a supported GPU, # The accelerator is auto-detected by default (the Vulkan build for any supported GPU,
# otherwise a plain CPU build). Upstream does not publish CUDA builds for Linux, so # otherwise a plain CPU build). Vulkan covers NVIDIA, AMD, and Intel GPUs on Linux;
# NVIDIA GPUs are served the Vulkan build, which their driver supports. # upstream ships no CUDA build, and the ROCm build is intentionally not offered here
# because it is complex to provision and Vulkan matches or beats it in practice.
set -euo pipefail set -euo pipefail
@ -19,17 +20,17 @@ REPO="ggml-org/llama.cpp"
# usage prints the command-line synopsis and supported environment variables. # usage prints the command-line synopsis and supported environment variables.
usage() { usage() {
echo "Usage: ${0##*/} [--auto|--cpu|--vulkan|--rocm|--sycl] [destdir] [version]" 1>&2 echo "Usage: ${0##*/} [--auto|--cpu|--vulkan|--sycl] [destdir] [version]" 1>&2
echo " ${0##*/} [--accel auto|cpu|vulkan|rocm|sycl] [destdir] [version]" 1>&2 echo " ${0##*/} [--accel auto|cpu|vulkan|sycl] [destdir] [version]" 1>&2
echo "" 1>&2 echo "" 1>&2
echo "Arguments:" 1>&2 echo "Arguments:" 1>&2
echo " destdir Install prefix (default: /usr/local); binaries land in <destdir>/bin." 1>&2 echo " destdir Install prefix (default: /usr/local); binaries land in <destdir>/bin." 1>&2
echo " version Release tag to install (e.g. b9948); defaults to the latest release." 1>&2 echo " version Release tag to install (e.g. b9948); defaults to the latest release." 1>&2
echo "" 1>&2 echo "" 1>&2
echo "Environment:" 1>&2 echo "Environment:" 1>&2
echo " PHOTOPRISM_LLAMA_ACCEL=auto|cpu|vulkan|rocm|sycl Accelerator to install." 1>&2 echo " PHOTOPRISM_LLAMA_ACCEL=auto|cpu|vulkan|sycl Accelerator to install." 1>&2
echo " PHOTOPRISM_ARCH / BUILD_ARCH Override target architecture." 1>&2 echo " PHOTOPRISM_ARCH / BUILD_ARCH Override target architecture." 1>&2
echo " LLAMA_SHA256 Verify the download against this checksum." 1>&2 echo " LLAMA_SHA256 Verify the download against this checksum." 1>&2
} }
# ACCEL selects the hardware backend; "auto" resolves it from the detected GPU below. # ACCEL selects the hardware backend; "auto" resolves it from the detected GPU below.
@ -45,12 +46,11 @@ while [[ $# -gt 0 ]]; do
--auto) ACCEL=auto; shift ;; --auto) ACCEL=auto; shift ;;
--cpu) ACCEL=cpu; shift ;; --cpu) ACCEL=cpu; shift ;;
--vulkan) ACCEL=vulkan; shift ;; --vulkan) ACCEL=vulkan; shift ;;
--rocm) ACCEL=rocm; shift ;;
--sycl) ACCEL=sycl; shift ;; --sycl) ACCEL=sycl; shift ;;
--accel) --accel)
ACCEL=${2:-} ACCEL=${2:-}
if [[ -z $ACCEL ]]; then if [[ -z $ACCEL ]]; then
echo "Error: --accel requires a value (auto, cpu, vulkan, rocm, or sycl)." 1>&2 echo "Error: --accel requires a value (auto, cpu, vulkan, or sycl)." 1>&2
exit 1 exit 1
fi fi
shift 2 shift 2
@ -66,9 +66,9 @@ done
# Normalize the accelerator selection to a known keyword. # Normalize the accelerator selection to a known keyword.
ACCEL=${ACCEL,,} ACCEL=${ACCEL,,}
case $ACCEL in case $ACCEL in
auto | cpu | vulkan | rocm | sycl) ;; auto | cpu | vulkan | sycl) ;;
gpu) ACCEL=auto ;; gpu) ACCEL=auto ;;
*) echo "Error: Unsupported accelerator \"$ACCEL\" (use auto, cpu, vulkan, rocm, or sycl)." 1>&2; exit 1 ;; *) echo "Error: Unsupported accelerator \"$ACCEL\" (use auto, cpu, vulkan, or sycl)." 1>&2; exit 1 ;;
esac esac
# You can provide a custom installation directory as the first positional argument. # You can provide a custom installation directory as the first positional argument.
@ -127,14 +127,6 @@ detect_gpu_vendors() {
# has_gpu returns success if the given GPU vendor was detected. # has_gpu returns success if the given GPU vendor was detected.
has_gpu() { [[ " $GPU_VENDORS " == *" $1 "* ]]; } has_gpu() { [[ " $GPU_VENDORS " == *" $1 "* ]]; }
# rocm_runtime_available returns success if a ROCm/HIP runtime is present on the host.
rocm_runtime_available() {
command -v rocminfo >/dev/null 2>&1 && return 0
[[ -d /opt/rocm ]] && return 0
ldconfig -p 2>/dev/null | grep -q 'libamdhip64\.so' && return 0
return 1
}
# vulkan_runtime_available returns success if the Vulkan loader is present on the host. # vulkan_runtime_available returns success if the Vulkan loader is present on the host.
vulkan_runtime_available() { vulkan_runtime_available() {
command -v vulkaninfo >/dev/null 2>&1 && return 0 command -v vulkaninfo >/dev/null 2>&1 && return 0
@ -142,19 +134,17 @@ vulkan_runtime_available() {
return 1 return 1
} }
# Resolve "auto" to a concrete accelerator based on the detected GPU: prefer ROCm for # Resolve "auto" to a concrete accelerator based on the detected GPU: the Vulkan build
# AMD GPUs with a ROCm runtime, otherwise Vulkan for any GPU (NVIDIA included), else CPU. # for any supported GPU (NVIDIA, AMD, or Intel), otherwise a plain CPU build.
if [[ $ACCEL == auto ]]; then if [[ $ACCEL == auto ]]; then
detect_gpu_vendors detect_gpu_vendors
echo "GPU detected: ${GPU_VENDORS:-none}" echo "GPU detected: ${GPU_VENDORS:-none}"
if [[ $DESTARCH == x64 ]] && has_gpu amd && rocm_runtime_available; then if [[ -n $GPU_VENDORS ]] && { has_gpu nvidia || has_gpu amd || has_gpu intel; }; then
ACCEL=rocm
elif [[ -n $GPU_VENDORS ]] && { has_gpu nvidia || has_gpu amd || has_gpu intel; }; then
ACCEL=vulkan ACCEL=vulkan
else else
ACCEL=cpu ACCEL=cpu
fi fi
echo "Selected accelerator: ${ACCEL} (override with --cpu/--vulkan/--rocm/--sycl)." echo "Selected accelerator: ${ACCEL} (override with --cpu/--vulkan/--sycl)."
fi fi
echo "Installing llama.cpp (${ACCEL}) for ${DESTARCH^^}..." echo "Installing llama.cpp (${ACCEL}) for ${DESTARCH^^}..."
@ -182,12 +172,10 @@ if [[ -z $TAG_NAME ]]; then
fi fi
# asset_pattern returns the regex matching the ubuntu asset for the given accelerator. # asset_pattern returns the regex matching the ubuntu asset for the given accelerator.
# ROCm and SYCL embed a runtime version in the file name, so match it with a wildcard.
asset_pattern() { asset_pattern() {
case $1 in case $1 in
cpu) echo "bin-ubuntu-${DESTARCH}\\.tar\\.gz$" ;; cpu) echo "bin-ubuntu-${DESTARCH}\\.tar\\.gz$" ;;
vulkan) echo "bin-ubuntu-vulkan-${DESTARCH}\\.tar\\.gz$" ;; vulkan) echo "bin-ubuntu-vulkan-${DESTARCH}\\.tar\\.gz$" ;;
rocm) echo "bin-ubuntu-rocm-.*-${DESTARCH}\\.tar\\.gz$" ;;
sycl) echo "bin-ubuntu-sycl-fp16-${DESTARCH}\\.tar\\.gz$" ;; sycl) echo "bin-ubuntu-sycl-fp16-${DESTARCH}\\.tar\\.gz$" ;;
esac esac
} }
@ -200,10 +188,9 @@ asset_url() {
jq -r --arg re "$re" '.assets[]? | select(.name | test($re)) | .browser_download_url' <<<"$RELEASE_JSON" | head -n1 jq -r --arg re "$re" '.assets[]? | select(.name | test($re)) | .browser_download_url' <<<"$RELEASE_JSON" | head -n1
} }
# Build a fallback chain so an unavailable accelerator degrades gracefully (e.g. ROCm # Build a fallback chain so an unavailable accelerator degrades to the plain CPU build
# has no ARM64 build, so it falls back to Vulkan and then to the plain CPU build). # (e.g. Vulkan or SYCL may be missing for a given arch in some releases).
case $ACCEL in case $ACCEL in
rocm) CANDIDATES=(rocm vulkan cpu) ;;
vulkan) CANDIDATES=(vulkan cpu) ;; vulkan) CANDIDATES=(vulkan cpu) ;;
sycl) CANDIDATES=(sycl cpu) ;; sycl) CANDIDATES=(sycl cpu) ;;
cpu) CANDIDATES=(cpu) ;; cpu) CANDIDATES=(cpu) ;;
@ -302,11 +289,6 @@ echo "Linked ${linked} executables into ${DESTDIR}/bin."
# Warn when the selected backend needs a runtime that is not present on this host. # Warn when the selected backend needs a runtime that is not present on this host.
case $RESOLVED_ACCEL in case $RESOLVED_ACCEL in
rocm)
if ! rocm_runtime_available; then
echo "Note: The ROCm build needs the ROCm/HIP runtime (e.g. libamdhip64.so) at runtime." 1>&2
fi
;;
vulkan) vulkan)
if ! vulkan_runtime_available; then if ! vulkan_runtime_available; then
echo "Note: The Vulkan build needs the Vulkan loader (libvulkan.so.1) and a GPU driver ICD at runtime." 1>&2 echo "Note: The Vulkan build needs the Vulkan loader (libvulkan.so.1) and a GPU driver ICD at runtime." 1>&2