diff --git a/scripts/dist/install-llamacpp.sh b/scripts/dist/install-llamacpp.sh index 08ea885f2..b020b1132 100755 --- a/scripts/dist/install-llamacpp.sh +++ b/scripts/dist/install-llamacpp.sh @@ -2,11 +2,12 @@ # 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) -- --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, -# otherwise a plain CPU build). Upstream does not publish CUDA builds for Linux, so -# NVIDIA GPUs are served the Vulkan build, which their driver supports. +# The accelerator is auto-detected by default (the Vulkan build for any supported GPU, +# otherwise a plain CPU build). Vulkan covers NVIDIA, AMD, and Intel GPUs on Linux; +# 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 @@ -19,17 +20,17 @@ REPO="ggml-org/llama.cpp" # usage prints the command-line synopsis and supported environment variables. usage() { - echo "Usage: ${0##*/} [--auto|--cpu|--vulkan|--rocm|--sycl] [destdir] [version]" 1>&2 - echo " ${0##*/} [--accel 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|sycl] [destdir] [version]" 1>&2 echo "" 1>&2 echo "Arguments:" 1>&2 echo " destdir Install prefix (default: /usr/local); binaries land in /bin." 1>&2 echo " version Release tag to install (e.g. b9948); defaults to the latest release." 1>&2 echo "" 1>&2 echo "Environment:" 1>&2 - echo " PHOTOPRISM_LLAMA_ACCEL=auto|cpu|vulkan|rocm|sycl Accelerator to install." 1>&2 - echo " PHOTOPRISM_ARCH / BUILD_ARCH Override target architecture." 1>&2 - echo " LLAMA_SHA256 Verify the download against this checksum." 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 " LLAMA_SHA256 Verify the download against this checksum." 1>&2 } # 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 ;; --cpu) ACCEL=cpu; shift ;; --vulkan) ACCEL=vulkan; shift ;; - --rocm) ACCEL=rocm; shift ;; --sycl) ACCEL=sycl; shift ;; --accel) ACCEL=${2:-} 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 fi shift 2 @@ -66,9 +66,9 @@ done # Normalize the accelerator selection to a known keyword. ACCEL=${ACCEL,,} case $ACCEL in - auto | cpu | vulkan | rocm | sycl) ;; + auto | cpu | vulkan | sycl) ;; 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 # 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() { [[ " $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() { command -v vulkaninfo >/dev/null 2>&1 && return 0 @@ -142,19 +134,17 @@ vulkan_runtime_available() { return 1 } -# Resolve "auto" to a concrete accelerator based on the detected GPU: prefer ROCm for -# AMD GPUs with a ROCm runtime, otherwise Vulkan for any GPU (NVIDIA included), else CPU. +# Resolve "auto" to a concrete accelerator based on the detected GPU: the Vulkan build +# for any supported GPU (NVIDIA, AMD, or Intel), otherwise a plain CPU build. if [[ $ACCEL == auto ]]; then detect_gpu_vendors echo "GPU detected: ${GPU_VENDORS:-none}" - if [[ $DESTARCH == x64 ]] && has_gpu amd && rocm_runtime_available; then - ACCEL=rocm - elif [[ -n $GPU_VENDORS ]] && { has_gpu nvidia || has_gpu amd || has_gpu intel; }; then + if [[ -n $GPU_VENDORS ]] && { has_gpu nvidia || has_gpu amd || has_gpu intel; }; then ACCEL=vulkan else ACCEL=cpu fi - echo "Selected accelerator: ${ACCEL} (override with --cpu/--vulkan/--rocm/--sycl)." + echo "Selected accelerator: ${ACCEL} (override with --cpu/--vulkan/--sycl)." fi echo "Installing llama.cpp (${ACCEL}) for ${DESTARCH^^}..." @@ -182,12 +172,10 @@ if [[ -z $TAG_NAME ]]; then fi # 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() { case $1 in cpu) echo "bin-ubuntu-${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$" ;; esac } @@ -200,10 +188,9 @@ asset_url() { 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 -# has no ARM64 build, so it falls back to Vulkan and then to the plain CPU build). +# Build a fallback chain so an unavailable accelerator degrades to the plain CPU build +# (e.g. Vulkan or SYCL may be missing for a given arch in some releases). case $ACCEL in - rocm) CANDIDATES=(rocm vulkan cpu) ;; vulkan) CANDIDATES=(vulkan cpu) ;; sycl) CANDIDATES=(sycl 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. 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) 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