2024-10-26 21:20:48 +02:00
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
2026-01-06 13:28:12 +01:00
|
|
|
|
# Copyright (c) 2021-2026 tteck
|
2025-04-30 10:10:03 +02:00
|
|
|
|
# Author: havardthom | Co-Author: MickLesk (CanbiZ)
|
2025-03-04 17:54:20 +01:00
|
|
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
|
|
|
|
|
# Source: https://ollama.com/
|
2024-10-26 21:20:48 +02:00
|
|
|
|
|
2025-03-24 14:20:56 +01:00
|
|
|
|
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
2024-10-26 21:20:48 +02:00
|
|
|
|
color
|
|
|
|
|
|
verb_ip6
|
|
|
|
|
|
catch_errors
|
|
|
|
|
|
setting_up_container
|
|
|
|
|
|
network_check
|
|
|
|
|
|
update_os
|
|
|
|
|
|
|
|
|
|
|
|
msg_info "Installing Dependencies"
|
2025-10-15 22:39:16 +02:00
|
|
|
|
$STD apt install -y \
|
2025-04-01 20:22:40 +02:00
|
|
|
|
build-essential \
|
2026-01-14 18:04:13 +01:00
|
|
|
|
pkg-config \
|
|
|
|
|
|
zstd
|
2024-10-26 21:20:48 +02:00
|
|
|
|
msg_ok "Installed Dependencies"
|
|
|
|
|
|
|
2026-06-22 04:45:41 +10:00
|
|
|
|
if [[ "$(arch_resolve)" == "amd64" ]]; then
|
2024-10-26 21:20:48 +02:00
|
|
|
|
msg_info "Setting up Intel® Repositories"
|
2025-10-15 22:39:16 +02:00
|
|
|
|
mkdir -p /usr/share/keyrings
|
2026-03-29 22:16:43 +02:00
|
|
|
|
curl -fsSL https://repositories.intel.com/gpu/intel-graphics.key | gpg --dearmor -o /usr/share/keyrings/intel-graphics.gpg 2>/dev/null || true
|
2025-10-15 22:39:16 +02:00
|
|
|
|
cat <<EOF >/etc/apt/sources.list.d/intel-gpu.sources
|
|
|
|
|
|
Types: deb
|
|
|
|
|
|
URIs: https://repositories.intel.com/gpu/ubuntu
|
|
|
|
|
|
Suites: jammy
|
|
|
|
|
|
Components: client
|
|
|
|
|
|
Architectures: amd64 i386
|
|
|
|
|
|
Signed-By: /usr/share/keyrings/intel-graphics.gpg
|
|
|
|
|
|
EOF
|
2026-03-29 22:16:43 +02:00
|
|
|
|
curl -fsSL https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor -o /usr/share/keyrings/oneapi-archive-keyring.gpg 2>/dev/null || true
|
2025-10-15 22:39:16 +02:00
|
|
|
|
cat <<EOF >/etc/apt/sources.list.d/oneAPI.sources
|
|
|
|
|
|
Types: deb
|
|
|
|
|
|
URIs: https://apt.repos.intel.com/oneapi
|
|
|
|
|
|
Suites: all
|
|
|
|
|
|
Components: main
|
|
|
|
|
|
Signed-By: /usr/share/keyrings/oneapi-archive-keyring.gpg
|
|
|
|
|
|
EOF
|
2026-09-24 08:06:49 +02:00
|
|
|
|
apt_update_safe
|
2024-10-26 21:20:48 +02:00
|
|
|
|
msg_ok "Set up Intel® Repositories"
|
|
|
|
|
|
|
2025-12-17 14:37:31 +01:00
|
|
|
|
msg_info "Installing Intel® Level Zero"
|
2026-01-02 21:21:06 +01:00
|
|
|
|
# Debian 13+ has newer Level Zero packages in system repos that conflict with Intel repo packages
|
|
|
|
|
|
if is_debian && [[ "$(get_os_version_major)" -ge 13 ]]; then
|
|
|
|
|
|
# Use system packages on Debian 13+ (avoid conflicts with libze1)
|
|
|
|
|
|
$STD apt -y install libze1 libze-dev intel-level-zero-gpu 2>/dev/null || {
|
|
|
|
|
|
msg_warn "Failed to install some Level Zero packages, continuing anyway"
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
# Use Intel repository packages for older systems
|
|
|
|
|
|
$STD apt -y install intel-level-zero-gpu level-zero level-zero-dev 2>/dev/null || {
|
|
|
|
|
|
msg_warn "Failed to install Intel Level Zero packages, continuing anyway"
|
|
|
|
|
|
}
|
|
|
|
|
|
fi
|
2025-12-17 14:37:31 +01:00
|
|
|
|
msg_ok "Installed Intel® Level Zero"
|
2024-10-26 21:20:48 +02:00
|
|
|
|
|
|
|
|
|
|
msg_info "Installing Intel® oneAPI Base Toolkit (Patience)"
|
2025-10-15 22:39:16 +02:00
|
|
|
|
$STD apt install -y --no-install-recommends intel-basekit-2024.1
|
2024-10-26 21:20:48 +02:00
|
|
|
|
msg_ok "Installed Intel® oneAPI Base Toolkit"
|
2026-06-22 04:45:41 +10:00
|
|
|
|
fi
|
2024-10-26 21:20:48 +02:00
|
|
|
|
|
|
|
|
|
|
msg_info "Installing Ollama (Patience)"
|
2025-04-30 10:10:03 +02:00
|
|
|
|
OLLAMA_INSTALL_DIR="/usr/local/lib/ollama"
|
|
|
|
|
|
BINDIR="/usr/local/bin"
|
2026-05-16 00:45:51 +02:00
|
|
|
|
mkdir -p "$OLLAMA_INSTALL_DIR"
|
2026-06-22 04:45:41 +10:00
|
|
|
|
if ! fetch_and_deploy_gh_release "ollama-com" "ollama/ollama" "prebuild" "latest" "$OLLAMA_INSTALL_DIR" "ollama-linux-$(arch_resolve).tar.zst"; then
|
2026-05-16 00:45:51 +02:00
|
|
|
|
msg_error "Failed to download or deploy Ollama – check network connectivity and GitHub API availability"
|
2026-03-02 13:57:42 +01:00
|
|
|
|
exit 250
|
2025-04-30 10:10:03 +02:00
|
|
|
|
fi
|
2026-06-05 06:40:26 -04:00
|
|
|
|
# If /dev/kfd exists assume an AMD GPU is installed, and install ROCM support for ollama
|
|
|
|
|
|
if [[ -e /dev/kfd ]]; then
|
|
|
|
|
|
if ! fetch_and_deploy_gh_release "ollama-rocm-com" "ollama/ollama" "prebuild" "latest" "$OLLAMA_INSTALL_DIR/lib" "ollama-linux-amd64-rocm.tar.zst"; then
|
|
|
|
|
|
msg_error "Failed to download or deploy Ollama AMD ROCM suport – check network connectivity and GitHub API availability"
|
|
|
|
|
|
exit 250
|
|
|
|
|
|
fi
|
|
|
|
|
|
fi
|
2026-05-16 00:45:51 +02:00
|
|
|
|
ln -sf "$OLLAMA_INSTALL_DIR/bin/ollama" "$BINDIR/ollama"
|
|
|
|
|
|
msg_ok "Installed Ollama"
|
2025-04-30 10:10:03 +02:00
|
|
|
|
|
|
|
|
|
|
msg_info "Creating ollama User and Group"
|
|
|
|
|
|
if ! id ollama >/dev/null 2>&1; then
|
|
|
|
|
|
useradd -r -s /usr/sbin/nologin -U -m -d /usr/share/ollama ollama
|
|
|
|
|
|
fi
|
|
|
|
|
|
$STD usermod -aG ollama $(id -u -n)
|
|
|
|
|
|
msg_ok "Created ollama User and adjusted Groups"
|
2024-10-26 21:20:48 +02:00
|
|
|
|
|
2026-03-19 06:55:56 +01:00
|
|
|
|
setup_hwaccel "ollama"
|
|
|
|
|
|
|
2024-10-26 21:20:48 +02:00
|
|
|
|
msg_info "Creating Service"
|
|
|
|
|
|
cat <<EOF >/etc/systemd/system/ollama.service
|
|
|
|
|
|
[Unit]
|
|
|
|
|
|
Description=Ollama Service
|
|
|
|
|
|
After=network-online.target
|
|
|
|
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
|
|
Type=exec
|
2025-04-30 10:10:03 +02:00
|
|
|
|
ExecStart=/usr/local/bin/ollama serve
|
2024-10-26 21:20:48 +02:00
|
|
|
|
Environment=HOME=$HOME
|
|
|
|
|
|
Environment=OLLAMA_INTEL_GPU=true
|
|
|
|
|
|
Environment=OLLAMA_HOST=0.0.0.0
|
|
|
|
|
|
Environment=OLLAMA_NUM_GPU=999
|
|
|
|
|
|
Environment=SYCL_CACHE_PERSISTENT=1
|
|
|
|
|
|
Environment=ZES_ENABLE_SYSMAN=1
|
|
|
|
|
|
Restart=always
|
|
|
|
|
|
RestartSec=3
|
|
|
|
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
|
EOF
|
2026-06-05 06:40:26 -04:00
|
|
|
|
if [[ -e /dev/kfd ]]; then
|
|
|
|
|
|
sed -i '/Environment=OLLAMA_INTEL_GPU=true/a Environment=OLLAMA_IGPU_ENABLE=1' \
|
|
|
|
|
|
/etc/systemd/system/ollama.service
|
|
|
|
|
|
fi
|
2025-04-01 20:22:40 +02:00
|
|
|
|
systemctl enable -q --now ollama
|
2024-10-26 21:20:48 +02:00
|
|
|
|
msg_ok "Created Service"
|
|
|
|
|
|
|
|
|
|
|
|
motd_ssh
|
|
|
|
|
|
customize
|
2025-11-22 17:27:13 +01:00
|
|
|
|
cleanup_lxc
|