Detects the GPU (NVIDIA on Linux, Apple Silicon on macOS), picks the catalog models and builds that fit, installs vLLM or MLX without sudo, and runs the model server plus a web dashboard as user services. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
95 lines
3.5 KiB
Bash
Executable file
95 lines
3.5 KiB
Bash
Executable file
#!/bin/bash
|
|
# llm-host installer.
|
|
#
|
|
# /bin/bash -c "$(curl -fsSL https://git.neilbantoc.dev/pub/llm-host/raw/branch/main/install.sh)"
|
|
#
|
|
# Pass setup options after `--`, e.g. ... install.sh)" -- --default ornith-1.5-35b --yes
|
|
# Environment overrides: LLMHOST_REPO, LLMHOST_REF, LLMHOST_HOME.
|
|
#
|
|
# Installs only into your home directory (no sudo): uv, a private Python, this repo,
|
|
# the inference backend (vLLM on Linux+NVIDIA, MLX on Apple Silicon) and user services.
|
|
# Written for bash 3.2 so it runs on stock macOS.
|
|
set -euo pipefail
|
|
|
|
REPO="${LLMHOST_REPO:-https://git.neilbantoc.dev/pub/llm-host.git}"
|
|
REF="${LLMHOST_REF:-main}"
|
|
DATA="${LLMHOST_HOME:-$HOME/.local/share/llm-host}"
|
|
SRC="$DATA/src"
|
|
BIN="$HOME/.local/bin"
|
|
|
|
if [ -t 1 ]; then B=$'\033[1m'; R=$'\033[31m'; Y=$'\033[33m'; G=$'\033[32m'; N=$'\033[0m'; else B=""; R=""; Y=""; G=""; N=""; fi
|
|
say() { printf '%s==>%s %s\n' "$B" "$N" "$*"; }
|
|
warn() { printf '%sWarning:%s %s\n' "$Y" "$N" "$*" >&2; }
|
|
die() { printf '%sError:%s %s\n' "$R" "$N" "$*" >&2; exit 1; }
|
|
|
|
[ "${1:-}" = "--" ] && shift
|
|
|
|
# ---- platform checks: fail early with a useful message ----
|
|
OS="$(uname -s)"; ARCH="$(uname -m)"
|
|
case "$OS" in
|
|
Darwin)
|
|
[ "$ARCH" = "arm64" ] || die "llm-host needs Apple Silicon on macOS (MLX doesn't run on Intel Macs)."
|
|
if ! xcode-select -p >/dev/null 2>&1; then
|
|
die "Xcode Command Line Tools are needed for git. Run: xcode-select --install then re-run this installer."
|
|
fi
|
|
;;
|
|
Linux)
|
|
if ! command -v nvidia-smi >/dev/null 2>&1; then
|
|
die "No NVIDIA driver found (nvidia-smi is missing). llm-host on Linux needs an NVIDIA GPU with its driver installed."
|
|
fi
|
|
if ! nvidia-smi -L >/dev/null 2>&1; then
|
|
die "nvidia-smi can't talk to the NVIDIA driver. Fix the driver (a reboot after driver updates often helps), then re-run."
|
|
fi
|
|
if ! command -v cc >/dev/null 2>&1 && ! command -v gcc >/dev/null 2>&1; then
|
|
die "No C compiler found; vLLM's Triton kernels need one. Debian/Ubuntu/Pop!_OS: sudo apt install build-essential"
|
|
fi
|
|
;;
|
|
*) die "Unsupported OS: $OS (llm-host supports Linux with NVIDIA, and macOS on Apple Silicon)." ;;
|
|
esac
|
|
for tool in curl git; do
|
|
command -v "$tool" >/dev/null 2>&1 || die "$tool is required but not installed."
|
|
done
|
|
|
|
mkdir -p "$BIN" "$DATA"
|
|
|
|
# ---- uv (Python + package manager), installed per-user ----
|
|
UV="$(command -v uv 2>/dev/null || true)"
|
|
[ -z "$UV" ] && [ -x "$BIN/uv" ] && UV="$BIN/uv"
|
|
if [ -z "$UV" ]; then
|
|
say "Installing uv"
|
|
curl -LsSf https://astral.sh/uv/install.sh | env UV_NO_MODIFY_PATH=1 UV_INSTALL_DIR="$BIN" sh >/dev/null
|
|
UV="$BIN/uv"
|
|
fi
|
|
[ -x "$UV" ] || die "uv install failed"
|
|
|
|
# ---- llm-host itself ----
|
|
if [ -d "$SRC/.git" ]; then
|
|
say "Updating llm-host in $SRC"
|
|
git -C "$SRC" fetch --quiet --depth 1 origin "$REF"
|
|
git -C "$SRC" reset --quiet --hard FETCH_HEAD
|
|
else
|
|
say "Downloading llm-host to $SRC"
|
|
rm -rf "$SRC"
|
|
git clone --quiet --depth 1 --branch "$REF" "$REPO" "$SRC"
|
|
fi
|
|
|
|
# ---- a private Python for llm-host (stdlib only, no venv needed) ----
|
|
say "Setting up Python"
|
|
"$UV" python install 3.12 >/dev/null 2>&1 || die "couldn't install Python 3.12 with uv"
|
|
PY="$("$UV" python find --managed-python 3.12)"
|
|
[ -x "$PY" ] || die "couldn't locate the uv-managed Python"
|
|
|
|
cat > "$BIN/llmhost" <<EOF
|
|
#!/bin/sh
|
|
# llm-host launcher (generated by install.sh)
|
|
PYTHONPATH="$SRC" exec "$PY" -P -m llmhost "\$@"
|
|
EOF
|
|
chmod +x "$BIN/llmhost"
|
|
|
|
case ":$PATH:" in
|
|
*":$BIN:"*) ;;
|
|
*) warn "$BIN isn't on your PATH. Add this to your shell profile: export PATH=\"$BIN:\$PATH\"" ;;
|
|
esac
|
|
|
|
say "Running setup"
|
|
exec "$BIN/llmhost" setup "$@"
|