mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-03-09 15:34:57 +00:00
Compare commits
2 Commits
fix/alpine
...
feat/rocm-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec677f3953 | ||
|
|
c2f73865d1 |
129
misc/tools.func
129
misc/tools.func
@@ -969,43 +969,13 @@ verify_repo_available() {
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Ensure dependencies are installed (with apt/apk update caching)
|
||||
# Supports both Debian (apt/dpkg) and Alpine (apk) systems
|
||||
# Ensure dependencies are installed (with apt update caching)
|
||||
# ------------------------------------------------------------------------------
|
||||
ensure_dependencies() {
|
||||
local deps=("$@")
|
||||
local missing=()
|
||||
|
||||
# Detect Alpine Linux
|
||||
if [[ -f /etc/alpine-release ]]; then
|
||||
for dep in "${deps[@]}"; do
|
||||
if command -v "$dep" &>/dev/null; then
|
||||
continue
|
||||
fi
|
||||
if apk info -e "$dep" &>/dev/null; then
|
||||
continue
|
||||
fi
|
||||
missing+=("$dep")
|
||||
done
|
||||
|
||||
if [[ ${#missing[@]} -gt 0 ]]; then
|
||||
$STD apk add --no-cache "${missing[@]}" || {
|
||||
local failed=()
|
||||
for pkg in "${missing[@]}"; do
|
||||
if ! $STD apk add --no-cache "$pkg" 2>/dev/null; then
|
||||
failed+=("$pkg")
|
||||
fi
|
||||
done
|
||||
if [[ ${#failed[@]} -gt 0 ]]; then
|
||||
msg_error "Failed to install dependencies: ${failed[*]}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Debian/Ubuntu: Fast batch check using dpkg-query
|
||||
# Fast batch check using dpkg-query (much faster than individual checks)
|
||||
local installed_pkgs
|
||||
installed_pkgs=$(dpkg-query -W -f='${Package}\n' 2>/dev/null | sort -u)
|
||||
|
||||
@@ -1102,15 +1072,11 @@ create_temp_dir() {
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Check if package is installed (supports both Debian and Alpine)
|
||||
# Check if package is installed (faster than dpkg -l | grep)
|
||||
# ------------------------------------------------------------------------------
|
||||
is_package_installed() {
|
||||
local package="$1"
|
||||
if [[ -f /etc/alpine-release ]]; then
|
||||
apk info -e "$package" &>/dev/null
|
||||
else
|
||||
dpkg-query -W -f='${Status}' "$package" 2>/dev/null | grep -q "^install ok installed$"
|
||||
fi
|
||||
dpkg-query -W -f='${Status}' "$package" 2>/dev/null | grep -q "^install ok installed$"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
@@ -4546,9 +4512,8 @@ _setup_amd_gpu() {
|
||||
fi
|
||||
# Ubuntu includes AMD firmware in linux-firmware by default
|
||||
|
||||
# ROCm for compute (optional - large download)
|
||||
# Uncomment if needed:
|
||||
# $STD apt -y install rocm-opencl-runtime 2>/dev/null || true
|
||||
# ROCm compute stack (OpenCL + HIP)
|
||||
_setup_rocm "$os_id" "$os_codename"
|
||||
|
||||
msg_ok "AMD GPU configured"
|
||||
}
|
||||
@@ -4573,9 +4538,91 @@ _setup_amd_apu() {
|
||||
$STD apt -y install firmware-amd-graphics 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# ROCm compute stack (OpenCL + HIP) - also works for many APUs
|
||||
_setup_rocm "$os_id" "$os_codename"
|
||||
|
||||
msg_ok "AMD APU configured"
|
||||
}
|
||||
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
# AMD ROCm Compute Setup
|
||||
# Adds ROCm repository and installs the ROCm compute stack for AMD GPUs/APUs.
|
||||
# Provides: OpenCL, HIP, rocm-smi, rocminfo
|
||||
# Supported: Debian 12/13, Ubuntu 22.04/24.04 (amd64 only)
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
_setup_rocm() {
|
||||
local os_id="$1" os_codename="$2"
|
||||
|
||||
# Only amd64 is supported
|
||||
if [[ "$(dpkg --print-architecture 2>/dev/null)" != "amd64" ]]; then
|
||||
msg_warn "ROCm is only available for amd64 — skipping"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local ROCM_VERSION="7.2"
|
||||
local ROCM_REPO_CODENAME
|
||||
|
||||
# Map OS codename to ROCm repository codename (Ubuntu-based repos)
|
||||
case "${os_id}-${os_codename}" in
|
||||
debian-bookworm) ROCM_REPO_CODENAME="jammy" ;;
|
||||
debian-trixie | debian-sid) ROCM_REPO_CODENAME="noble" ;;
|
||||
ubuntu-jammy) ROCM_REPO_CODENAME="jammy" ;;
|
||||
ubuntu-noble) ROCM_REPO_CODENAME="noble" ;;
|
||||
*)
|
||||
msg_warn "ROCm not supported on ${os_id} ${os_codename} — skipping"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
msg_info "Installing ROCm ${ROCM_VERSION} compute stack"
|
||||
|
||||
# ROCm main repository (userspace only — kernel driver runs on host)
|
||||
setup_deb822_repo \
|
||||
"rocm" \
|
||||
"https://repo.radeon.com/rocm/rocm.gpg.key" \
|
||||
"https://repo.radeon.com/rocm/apt/${ROCM_VERSION}" \
|
||||
"${ROCM_REPO_CODENAME}" \
|
||||
"main" \
|
||||
"amd64" || {
|
||||
msg_warn "Failed to add ROCm repository — skipping ROCm"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Pin ROCm packages to prefer radeon repo
|
||||
cat <<EOF >/etc/apt/preferences.d/rocm-pin-600
|
||||
Package: *
|
||||
Pin: release o=repo.radeon.com
|
||||
Pin-Priority: 600
|
||||
EOF
|
||||
|
||||
$STD apt update
|
||||
$STD apt install -y rocm 2>/dev/null || {
|
||||
msg_warn "ROCm meta-package install failed — trying minimal set"
|
||||
$STD apt install -y rocm-opencl-runtime rocm-smi-lib 2>/dev/null || msg_warn "ROCm minimal install also failed"
|
||||
}
|
||||
|
||||
# Group membership for GPU access
|
||||
usermod -aG render,video root 2>/dev/null || true
|
||||
|
||||
# Environment (PATH + LD_LIBRARY_PATH)
|
||||
if [[ -d /opt/rocm ]]; then
|
||||
cat <<'ENVEOF' >/etc/profile.d/rocm.sh
|
||||
export PATH="\$PATH:/opt/rocm/bin"
|
||||
export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH:+\$LD_LIBRARY_PATH:}/opt/rocm/lib"
|
||||
ENVEOF
|
||||
chmod +x /etc/profile.d/rocm.sh
|
||||
# Also make available for current session / systemd services
|
||||
echo "/opt/rocm/lib" >/etc/ld.so.conf.d/rocm.conf
|
||||
ldconfig 2>/dev/null || true
|
||||
fi
|
||||
|
||||
if [[ -x /opt/rocm/bin/rocminfo ]]; then
|
||||
msg_ok "ROCm ${ROCM_VERSION} installed"
|
||||
else
|
||||
msg_warn "ROCm installed but rocminfo not found — GPU may not be available in container"
|
||||
fi
|
||||
}
|
||||
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
# NVIDIA GPU Setup
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user