mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-12-17 20:53:28 +01:00
use setup_hwaccel for robust hardware acceleration (#10054)
* fix(jellyfin): use setup_hwaccel for robust hardware acceleration Replaces manual hardware acceleration setup with the centralized setup_hwaccel function from tools.func. This fixes the installation failure in privileged containers where /dev/dri does not exist (e.g., when no GPU is passed through). The setup_hwaccel function includes: - Proper error handling for missing /dev/dri - GPU vendor detection (Intel, AMD, NVIDIA) - Graceful fallback when no GPU is available Fixes: Installation fails with 'chgrp: cannot access /dev/dri' when creating privileged containers without GPU passthrough. * refactor(hwaccel): standardize hardware acceleration across all install scripts Migrated all install scripts to use the centralized setup_hwaccel function: - plex-install.sh - emby-install.sh - ersatztv-install.sh - frigate-install.sh - tdarr-install.sh - unmanic-install.sh - channels-install.sh - ollama-install.sh - immich-install.sh (added error handling) Enhanced setup_hwaccel function in tools.func: - Added -d /dev/dri check before setting permissions - Added error handling (2>/dev/null || true) for all /dev/dri operations - Added adduser error handling for video/render groups - No longer fails if no GPU is detected (graceful skip) - Added intel-media-va-driver for newer Intel GPUs - Improved AMD APU support with firmware packages - Better NVIDIA handling (warning instead of failure) This fixes installation failures in privileged containers without GPU passthrough, where /dev/dri does not exist. Supports: Ubuntu, Debian 12 (Bookworm), Debian 13 (Trixie) GPU Support: Intel, AMD, NVIDIA (manual driver) * refactor(hwaccel): complete migration for all GPU apps Migrated remaining GPU apps to setup_hwaccel: - fileflows-install.sh - openwebui-install.sh (added setup_hwaccel - was missing) - tunarr-install.sh Also fixed tools/pve/hw-acceleration.sh: - Added error handling for /dev/dri operations - Added chmod 660 /dev/dri/* that was missing - Added error suppression for adduser commands All 13 GPU apps (var_gpu=yes) now use centralized setup_hwaccel: jellyfin, plex, emby, ersatztv, frigate, tdarr, unmanic, channels, ollama, immich, fileflows, openwebui, tunarr * feat(hwaccel): complete Intel non-free driver support and GID sync Enhanced setup_hwaccel function: - Auto-detect Intel GPU generation (Gen 9+ for non-free drivers) - Debian 12 (Bookworm): Add non-free repo + intel-media-va-driver-non-free - Debian 13 (Trixie): Add non-free repo + libvpl2 + mesa-opencl-icd - Ubuntu: Use ubuntu repos with intel-media-va-driver - Fallback to open drivers if non-free fails - GID sync for video/render groups (moved from install scripts) OpenWebUI: Added Intel oneAPI support when installing Ollama - Intel Level Zero GPU support - Intel oneAPI Base Toolkit - Same setup as standalone Ollama install Cleanup: - Removed duplicate GID sync from tdarr-install.sh - Removed duplicate GID sync from unmanic-install.sh * fix(ersatztv): remove duplicate HW acceleration code Removed manual Intel HW acceleration setup that remained after setup_hwaccel migration. The non-free driver prompt is no longer needed as setup_hwaccel auto-detects Intel GPU generation.
This commit is contained in:
committed by
GitHub
parent
8e3da31471
commit
3a9d03fdb7
@ -29,19 +29,7 @@ if [[ ! "$CONFIRM" =~ ^([yY][eE][sS]|[yY])$ ]]; then
|
||||
exit 10
|
||||
fi
|
||||
|
||||
if [[ "$CTTYPE" == "0" ]]; then
|
||||
msg_info "Setting Up Hardware Acceleration"
|
||||
$STD apt-get -y install \
|
||||
va-driver-all \
|
||||
ocl-icd-libopencl1 \
|
||||
intel-opencl-icd
|
||||
chgrp video /dev/dri
|
||||
chmod 755 /dev/dri
|
||||
chmod 660 /dev/dri/*
|
||||
$STD adduser $(id -u -n) video
|
||||
$STD adduser $(id -u -n) render
|
||||
msg_ok "Set Up Hardware Acceleration"
|
||||
fi
|
||||
setup_hwaccel
|
||||
|
||||
msg_info "Installing Channels DVR Server (Patience)"
|
||||
cd /opt
|
||||
|
||||
@ -13,16 +13,7 @@ setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Setting Up Hardware Acceleration"
|
||||
$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
|
||||
if [[ "$CTTYPE" == "0" ]]; then
|
||||
chgrp video /dev/dri
|
||||
chmod 755 /dev/dri
|
||||
chmod 660 /dev/dri/*
|
||||
$STD adduser $(id -u -n) video
|
||||
$STD adduser $(id -u -n) render
|
||||
fi
|
||||
msg_ok "Set Up Hardware Acceleration"
|
||||
setup_hwaccel
|
||||
|
||||
fetch_and_deploy_gh_release "emby" "MediaBrowser/Emby.Releases" "binary"
|
||||
|
||||
|
||||
@ -13,38 +13,7 @@ setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Setting Up Hardware Acceleration"
|
||||
$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
|
||||
if [[ "$CTTYPE" == "0" ]]; then
|
||||
chgrp video /dev/dri
|
||||
chmod 755 /dev/dri
|
||||
chmod 660 /dev/dri/*
|
||||
$STD adduser $(id -u -n) video
|
||||
$STD adduser $(id -u -n) render
|
||||
fi
|
||||
msg_ok "Set Up Hardware Acceleration"
|
||||
|
||||
read -r -p "${TAB3}Do you need the intel-media-va-driver-non-free driver for HW encoding (Debian 12 only)? <y/N> " prompt
|
||||
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
||||
msg_info "Installing Intel Hardware Acceleration (non-free)"
|
||||
cat <<EOF >/etc/apt/sources.list.d/non-free.list
|
||||
|
||||
deb http://deb.debian.org/debian bookworm non-free non-free-firmware
|
||||
deb-src http://deb.debian.org/debian bookworm non-free non-free-firmware
|
||||
|
||||
deb http://deb.debian.org/debian-security bookworm-security non-free non-free-firmware
|
||||
deb-src http://deb.debian.org/debian-security bookworm-security non-free non-free-firmware
|
||||
|
||||
deb http://deb.debian.org/debian bookworm-updates non-free non-free-firmware
|
||||
deb-src http://deb.debian.org/debian bookworm-updates non-free non-free-firmware
|
||||
EOF
|
||||
$STD apt-get update
|
||||
$STD apt-get -y install {intel-media-va-driver-non-free,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
|
||||
else
|
||||
msg_info "Installing Intel Hardware Acceleration"
|
||||
$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
|
||||
fi
|
||||
msg_ok "Installed and Set Up Intel Hardware Acceleration"
|
||||
setup_hwaccel
|
||||
|
||||
fetch_and_deploy_gh_release "ersatztv" "ErsatzTV/ErsatzTV" "prebuild" "latest" "/opt/ErsatzTV" "*linux-x64.tar.gz"
|
||||
fetch_and_deploy_gh_release "ersatztv-ffmpeg" "ErsatzTV/ErsatzTV-ffmpeg" "prebuild" "latest" "/opt/ErsatzTV-ffmpeg" "*-linux64-gpl-7.1.tar.xz"
|
||||
|
||||
@ -21,27 +21,7 @@ $STD apt-get install -y \
|
||||
imagemagick
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
read -r -p "${TAB3}Do you need the intel-media-va-driver-non-free driver for HW encoding (Debian 12 only)? <y/N> " prompt
|
||||
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
||||
msg_info "Installing Intel Hardware Acceleration (non-free)"
|
||||
cat <<EOF >/etc/apt/sources.list.d/non-free.list
|
||||
|
||||
deb http://deb.debian.org/debian bookworm non-free non-free-firmware
|
||||
deb-src http://deb.debian.org/debian bookworm non-free non-free-firmware
|
||||
|
||||
deb http://deb.debian.org/debian-security bookworm-security non-free non-free-firmware
|
||||
deb-src http://deb.debian.org/debian-security bookworm-security non-free non-free-firmware
|
||||
|
||||
deb http://deb.debian.org/debian bookworm-updates non-free non-free-firmware
|
||||
deb-src http://deb.debian.org/debian bookworm-updates non-free non-free-firmware
|
||||
EOF
|
||||
$STD apt-get update
|
||||
$STD apt-get -y install {intel-media-va-driver-non-free,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
|
||||
else
|
||||
msg_info "Installing Intel Hardware Acceleration"
|
||||
$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
|
||||
fi
|
||||
msg_ok "Installed and Set Up Intel Hardware Acceleration"
|
||||
setup_hwaccel
|
||||
|
||||
msg_info "Installing ASP.NET Core Runtime"
|
||||
curl -fsSL https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -o packages-microsoft-prod.deb
|
||||
|
||||
@ -33,14 +33,7 @@ chmod +x go2rtc
|
||||
$STD ln -svf /usr/local/go2rtc/bin/go2rtc /usr/local/bin/go2rtc
|
||||
msg_ok "Installed go2rtc"
|
||||
|
||||
msg_info "Setting Up Hardware Acceleration"
|
||||
$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
|
||||
if [[ "$CTTYPE" == "0" ]]; then
|
||||
chgrp video /dev/dri
|
||||
chmod 755 /dev/dri
|
||||
chmod 660 /dev/dri/*
|
||||
fi
|
||||
msg_ok "Set Up Hardware Acceleration"
|
||||
setup_hwaccel
|
||||
|
||||
msg_info "Installing Frigate v0.14.1 (Perseverance)"
|
||||
cd ~
|
||||
|
||||
@ -75,12 +75,13 @@ $STD apt install -y jellyfin-ffmpeg7
|
||||
ln -sf /usr/lib/jellyfin-ffmpeg/ffmpeg /usr/bin/ffmpeg
|
||||
ln -sf /usr/lib/jellyfin-ffmpeg/ffprobe /usr/bin/ffprobe
|
||||
|
||||
# Set permissions for /dev/dri (only in privileged containers and if /dev/dri exists)
|
||||
if [[ "$CTTYPE" == "0" && -d /dev/dri ]]; then
|
||||
chgrp video /dev/dri
|
||||
chmod 755 /dev/dri
|
||||
chmod 660 /dev/dri/*
|
||||
$STD adduser "$(id -u -n)" video
|
||||
$STD adduser "$(id -u -n)" render
|
||||
chgrp video /dev/dri 2>/dev/null || true
|
||||
chmod 755 /dev/dri 2>/dev/null || true
|
||||
chmod 660 /dev/dri/* 2>/dev/null || true
|
||||
$STD adduser "$(id -u -n)" video 2>/dev/null || true
|
||||
$STD adduser "$(id -u -n)" render 2>/dev/null || true
|
||||
fi
|
||||
msg_ok "Dependencies Installed"
|
||||
|
||||
|
||||
@ -13,25 +13,7 @@ setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Setting Up Hardware Acceleration"
|
||||
if ! grep -qEi 'ubuntu' /etc/os-release; then
|
||||
fetch_and_deploy_gh_release "intel-igc-core-2" "intel/intel-graphics-compiler" "binary" "latest" "" "intel-igc-core-2_*_amd64.deb"
|
||||
fetch_and_deploy_gh_release "intel-igc-opencl-2" "intel/intel-graphics-compiler" "binary" "latest" "" "intel-igc-opencl-2_*_amd64.deb"
|
||||
fetch_and_deploy_gh_release "intel-libgdgmm12" "intel/compute-runtime" "binary" "latest" "" "libigdgmm12_*_amd64.deb"
|
||||
fetch_and_deploy_gh_release "intel-opencl-icd" "intel/compute-runtime" "binary" "latest" "" "intel-opencl-icd_*_amd64.deb"
|
||||
else
|
||||
$STD apt -y install intel-opencl-icd
|
||||
fi
|
||||
|
||||
$STD apt -y install {va-driver-all,ocl-icd-libopencl1,vainfo,intel-gpu-tools}
|
||||
if [[ "$CTTYPE" == "0" ]]; then
|
||||
chgrp video /dev/dri
|
||||
chmod 755 /dev/dri
|
||||
chmod 660 /dev/dri/*
|
||||
$STD adduser $(id -u -n) video
|
||||
$STD adduser $(id -u -n) render
|
||||
fi
|
||||
msg_ok "Set Up Hardware Acceleration"
|
||||
setup_hwaccel
|
||||
|
||||
msg_info "Installing Jellyfin"
|
||||
VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)"
|
||||
|
||||
@ -41,16 +41,11 @@ EOF
|
||||
$STD apt update
|
||||
msg_ok "Set up Intel® Repositories"
|
||||
|
||||
msg_info "Setting Up Hardware Acceleration"
|
||||
$STD apt -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools,intel-level-zero-gpu,level-zero,level-zero-dev}
|
||||
if [[ "$CTTYPE" == "0" ]]; then
|
||||
chgrp video /dev/dri
|
||||
chmod 755 /dev/dri
|
||||
chmod 660 /dev/dri/*
|
||||
$STD adduser $(id -u -n) video
|
||||
$STD adduser $(id -u -n) render
|
||||
fi
|
||||
msg_ok "Set Up Hardware Acceleration"
|
||||
setup_hwaccel
|
||||
|
||||
msg_info "Installing Intel® Level Zero"
|
||||
$STD apt -y install intel-level-zero-gpu level-zero level-zero-dev 2>/dev/null || true
|
||||
msg_ok "Installed Intel® Level Zero"
|
||||
|
||||
msg_info "Installing Intel® oneAPI Base Toolkit (Patience)"
|
||||
$STD apt install -y --no-install-recommends intel-basekit-2024.1
|
||||
|
||||
@ -17,6 +17,8 @@ msg_info "Installing Dependencies"
|
||||
$STD apt install -y ffmpeg
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
setup_hwaccel
|
||||
|
||||
PYTHON_VERSION="3.12" setup_uv
|
||||
|
||||
msg_info "Installing Open WebUI"
|
||||
@ -25,6 +27,36 @@ msg_ok "Installed Open WebUI"
|
||||
|
||||
read -r -p "${TAB3}Would you like to add Ollama? <y/N> " prompt
|
||||
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
||||
msg_info "Setting up Intel® Repositories"
|
||||
mkdir -p /usr/share/keyrings
|
||||
curl -fsSL https://repositories.intel.com/gpu/intel-graphics.key | gpg --dearmor -o /usr/share/keyrings/intel-graphics.gpg 2>/dev/null || true
|
||||
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
|
||||
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
|
||||
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
|
||||
$STD apt update
|
||||
msg_ok "Set up Intel® Repositories"
|
||||
|
||||
msg_info "Installing Intel® Level Zero"
|
||||
$STD apt -y install intel-level-zero-gpu level-zero level-zero-dev 2>/dev/null || true
|
||||
msg_ok "Installed Intel® Level Zero"
|
||||
|
||||
msg_info "Installing Intel® oneAPI Base Toolkit (Patience)"
|
||||
$STD apt install -y --no-install-recommends intel-basekit-2024.1 2>/dev/null || true
|
||||
msg_ok "Installed Intel® oneAPI Base Toolkit"
|
||||
|
||||
msg_info "Installing Ollama"
|
||||
curl -fsSLO -C - https://ollama.com/download/ollama-linux-amd64.tgz
|
||||
tar -C /usr -xzf ollama-linux-amd64.tgz
|
||||
|
||||
@ -13,16 +13,7 @@ setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Setting Up Hardware Acceleration"
|
||||
$STD apt -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
|
||||
if [[ "$CTTYPE" == "0" ]]; then
|
||||
chgrp video /dev/dri
|
||||
chmod 755 /dev/dri
|
||||
chmod 660 /dev/dri/*
|
||||
$STD adduser $(id -u -n) video
|
||||
$STD adduser $(id -u -n) render
|
||||
fi
|
||||
msg_ok "Set Up Hardware Acceleration"
|
||||
setup_hwaccel
|
||||
|
||||
msg_info "Setting Up Plex Media Server Repository"
|
||||
curl -fsSL https://downloads.plex.tv/plex-keys/PlexSign.key | tee /usr/share/keyrings/PlexSign.asc >/dev/null
|
||||
|
||||
@ -28,32 +28,7 @@ $STD ./Tdarr_Updater
|
||||
rm -rf /opt/tdarr/Tdarr_Updater.zip
|
||||
msg_ok "Installed Tdarr"
|
||||
|
||||
msg_info "Setting Up Hardware Acceleration"
|
||||
$STD apt -y install \
|
||||
va-driver-all \
|
||||
ocl-icd-libopencl1 \
|
||||
vainfo \
|
||||
intel-gpu-tools \
|
||||
mesa-va-drivers \
|
||||
mesa-vdpau-drivers \
|
||||
intel-media-va-driver
|
||||
if [[ "$CTTYPE" == "0" ]]; then
|
||||
chgrp video /dev/dri
|
||||
chmod 755 /dev/dri
|
||||
chmod 660 /dev/dri/*
|
||||
$STD adduser $(id -u -n) video
|
||||
$STD adduser $(id -u -n) render
|
||||
VIDEO_GID=$(getent group video | cut -d: -f3)
|
||||
RENDER_GID=$(getent group render | cut -d: -f3)
|
||||
if [[ -n "$VIDEO_GID" && -n "$RENDER_GID" ]]; then
|
||||
sed -i "s/^video:x:[0-9]*:/video:x:$VIDEO_GID:/" /etc/group
|
||||
sed -i "s/^render:x:[0-9]*:/render:x:$RENDER_GID:/" /etc/group
|
||||
fi
|
||||
else
|
||||
VIDEO_GID=$(getent group video | cut -d: -f3)
|
||||
RENDER_GID=$(getent group render | cut -d: -f3)
|
||||
fi
|
||||
msg_ok "Set Up Hardware Acceleration"
|
||||
setup_hwaccel
|
||||
|
||||
msg_info "Creating Service"
|
||||
cat <<EOF >/etc/systemd/system/tdarr-server.service
|
||||
|
||||
@ -13,53 +13,7 @@ setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Setting Up Hardware Acceleration"
|
||||
if [[ "$CTTYPE" == "0" ]]; then
|
||||
$STD adduser "$(id -un)" video
|
||||
$STD adduser "$(id -un)" render
|
||||
fi
|
||||
msg_ok "Base Hardware Acceleration Set Up"
|
||||
|
||||
read -r -p "${TAB3}Do you need the intel-media-va-driver-non-free driver for HW encoding (Debian 13 only)? <y/N> " prompt
|
||||
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
||||
msg_info "Installing Intel Hardware Acceleration (non-free)"
|
||||
cat <<'EOF' >/etc/apt/sources.list.d/non-free.sources
|
||||
Types: deb deb-src
|
||||
URIs: http://deb.debian.org/debian
|
||||
Suites: trixie
|
||||
Components: non-free non-free-firmware
|
||||
|
||||
Types: deb deb-src
|
||||
URIs: http://deb.debian.org/debian-security
|
||||
Suites: trixie-security
|
||||
Components: non-free non-free-firmware
|
||||
|
||||
Types: deb deb-src
|
||||
URIs: http://deb.debian.org/debian
|
||||
Suites: trixie-updates
|
||||
Components: non-free non-free-firmware
|
||||
EOF
|
||||
|
||||
$STD apt update
|
||||
$STD apt -y install \
|
||||
intel-media-va-driver-non-free \
|
||||
ocl-icd-libopencl1 \
|
||||
mesa-opencl-icd \
|
||||
mesa-va-drivers \
|
||||
libvpl2 \
|
||||
vainfo \
|
||||
intel-gpu-tools
|
||||
else
|
||||
msg_info "Installing Intel Hardware Acceleration (open packages)"
|
||||
$STD apt -y install \
|
||||
va-driver-all \
|
||||
ocl-icd-libopencl1 \
|
||||
mesa-opencl-icd \
|
||||
mesa-va-drivers \
|
||||
vainfo \
|
||||
intel-gpu-tools
|
||||
fi
|
||||
msg_ok "Installed and Set Up Intel Hardware Acceleration"
|
||||
setup_hwaccel
|
||||
|
||||
fetch_and_deploy_gh_release "tunarr" "chrisbenincasa/tunarr" "prebuild" "latest" "/opt/tunarr" "*linux-x64.tar.gz"
|
||||
cd /opt/tunarr
|
||||
|
||||
@ -19,32 +19,7 @@ $STD apt install -y \
|
||||
python3-pip
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
msg_info "Setting Up Hardware Acceleration"
|
||||
$STD apt -y install \
|
||||
va-driver-all \
|
||||
ocl-icd-libopencl1 \
|
||||
vainfo \
|
||||
intel-gpu-tools \
|
||||
mesa-va-drivers \
|
||||
mesa-vdpau-drivers \
|
||||
intel-media-va-driver
|
||||
if [[ "$CTTYPE" == "0" ]]; then
|
||||
chgrp video /dev/dri
|
||||
chmod 755 /dev/dri
|
||||
chmod 660 /dev/dri/*
|
||||
$STD adduser $(id -u -n) video
|
||||
$STD adduser $(id -u -n) render
|
||||
VIDEO_GID=$(getent group video | cut -d: -f3)
|
||||
RENDER_GID=$(getent group render | cut -d: -f3)
|
||||
if [[ -n "$VIDEO_GID" && -n "$RENDER_GID" ]]; then
|
||||
sed -i "s/^video:x:[0-9]*:/video:x:$VIDEO_GID:/" /etc/group
|
||||
sed -i "s/^render:x:[0-9]*:/render:x:$RENDER_GID:/" /etc/group
|
||||
fi
|
||||
else
|
||||
VIDEO_GID=$(getent group video | cut -d: -f3)
|
||||
RENDER_GID=$(getent group render | cut -d: -f3)
|
||||
fi
|
||||
msg_ok "Set Up Hardware Acceleration"
|
||||
setup_hwaccel
|
||||
|
||||
msg_info "Installing Unmanic"
|
||||
$STD pip3 install unmanic
|
||||
|
||||
213
misc/tools.func
213
misc/tools.func
@ -1460,19 +1460,19 @@ check_for_gh_release() {
|
||||
|
||||
# Try /latest endpoint for non-pinned versions (most efficient)
|
||||
local releases_json=""
|
||||
|
||||
|
||||
if [[ -z "$pinned_version_in" ]]; then
|
||||
releases_json=$(curl -fsSL --max-time 20 \
|
||||
-H 'Accept: application/vnd.github+json' \
|
||||
-H 'X-GitHub-Api-Version: 2022-11-28' \
|
||||
"https://api.github.com/repos/${source}/releases/latest" 2>/dev/null)
|
||||
|
||||
|
||||
if [[ $? -eq 0 ]] && [[ -n "$releases_json" ]]; then
|
||||
# Wrap single release in array for consistent processing
|
||||
releases_json="[$releases_json]"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# If no releases yet (pinned version OR /latest failed), fetch up to 100
|
||||
if [[ -z "$releases_json" ]]; then
|
||||
# Fetch releases and exclude drafts/prereleases
|
||||
@ -2585,93 +2585,200 @@ function setup_hwaccel() {
|
||||
fi
|
||||
|
||||
# Detect GPU vendor (Intel, AMD, NVIDIA)
|
||||
local gpu_vendor
|
||||
gpu_vendor=$(lspci 2>/dev/null | grep -Ei 'vga|3d|display' | grep -Eo 'Intel|AMD|NVIDIA' | head -n1 || echo "")
|
||||
local gpu_vendor gpu_info
|
||||
gpu_info=$(lspci 2>/dev/null | grep -Ei 'vga|3d|display' || echo "")
|
||||
gpu_vendor=$(echo "$gpu_info" | grep -Eo 'Intel|AMD|NVIDIA' | head -n1 || echo "")
|
||||
|
||||
# Detect CPU vendor (relevant for AMD APUs)
|
||||
local cpu_vendor
|
||||
cpu_vendor=$(lscpu 2>/dev/null | grep -i 'Vendor ID' | awk '{print $3}' || echo "")
|
||||
|
||||
if [[ -z "$gpu_vendor" && -z "$cpu_vendor" ]]; then
|
||||
msg_error "No GPU or CPU vendor detected (missing lspci/lscpu output)"
|
||||
return 1
|
||||
msg_warn "No GPU or CPU vendor detected - skipping hardware acceleration setup"
|
||||
msg_ok "Setup Hardware Acceleration (skipped - no GPU detected)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Detect OS with fallbacks
|
||||
local os_id os_codename
|
||||
os_id=$(grep -oP '(?<=^ID=).+' /etc/os-release 2>/dev/null | tr -d '"' || grep '^ID=' /etc/os-release 2>/dev/null | cut -d'=' -f2 | tr -d '"' || echo "debian")
|
||||
os_codename=$(grep -oP '(?<=^VERSION_CODENAME=).+' /etc/os-release 2>/dev/null | tr -d '"' || grep '^VERSION_CODENAME=' /etc/os-release 2>/dev/null | cut -d'=' -f2 | tr -d '"' || echo "unknown")
|
||||
local os_id os_codename os_version
|
||||
os_id=$(grep -oP '(?<=^ID=).+' /etc/os-release 2>/dev/null | tr -d '"' || echo "debian")
|
||||
os_codename=$(grep -oP '(?<=^VERSION_CODENAME=).+' /etc/os-release 2>/dev/null | tr -d '"' || echo "unknown")
|
||||
os_version=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release 2>/dev/null | tr -d '"' || echo "")
|
||||
|
||||
# Validate os_id
|
||||
if [[ -z "$os_id" ]]; then
|
||||
os_id="debian"
|
||||
fi
|
||||
[[ -z "$os_id" ]] && os_id="debian"
|
||||
|
||||
# Determine if we are on a VM or LXC
|
||||
# Determine if we are in a privileged LXC container
|
||||
local in_ct="${CTTYPE:-0}"
|
||||
|
||||
case "$gpu_vendor" in
|
||||
Intel)
|
||||
if [[ "$os_id" == "ubuntu" ]]; then
|
||||
$STD apt -y install intel-opencl-icd || {
|
||||
msg_error "Failed to install intel-opencl-icd"
|
||||
return 1
|
||||
}
|
||||
else
|
||||
# For Debian: fetch Intel GPU drivers from GitHub
|
||||
fetch_and_deploy_gh_release "" "intel/intel-graphics-compiler" "binary" "latest" "" "intel-igc-core-2_*_amd64.deb" || {
|
||||
msg_warn "Failed to deploy Intel IGC core 2"
|
||||
}
|
||||
fetch_and_deploy_gh_release "" "intel/intel-graphics-compiler" "binary" "latest" "" "intel-igc-opencl-2_*_amd64.deb" || {
|
||||
msg_warn "Failed to deploy Intel IGC OpenCL 2"
|
||||
}
|
||||
fetch_and_deploy_gh_release "" "intel/compute-runtime" "binary" "latest" "" "libigdgmm12_*_amd64.deb" || {
|
||||
msg_warn "Failed to deploy Intel GDGMM12"
|
||||
}
|
||||
fetch_and_deploy_gh_release "" "intel/compute-runtime" "binary" "latest" "" "intel-opencl-icd_*_amd64.deb" || {
|
||||
msg_warn "Failed to deploy Intel OpenCL ICD"
|
||||
}
|
||||
# Detect Intel GPU generation for driver selection
|
||||
# Gen 9+ (Skylake and newer) benefit from non-free drivers
|
||||
local intel_gen=""
|
||||
local needs_nonfree=false
|
||||
|
||||
# Check for specific Intel GPU models that need non-free drivers
|
||||
if echo "$gpu_info" | grep -Ei 'HD Graphics [56][0-9]{2}|UHD Graphics|Iris|Arc|DG[12]' &>/dev/null; then
|
||||
needs_nonfree=true
|
||||
intel_gen="gen9+"
|
||||
fi
|
||||
|
||||
$STD apt -y install va-driver-all ocl-icd-libopencl1 vainfo intel-gpu-tools || {
|
||||
msg_error "Failed to install Intel GPU dependencies"
|
||||
return 1
|
||||
}
|
||||
if [[ "$os_id" == "ubuntu" ]]; then
|
||||
# Ubuntu: Use packages from Ubuntu repos
|
||||
$STD apt -y install \
|
||||
va-driver-all \
|
||||
ocl-icd-libopencl1 \
|
||||
intel-opencl-icd \
|
||||
vainfo \
|
||||
intel-gpu-tools || {
|
||||
msg_error "Failed to install Intel GPU dependencies"
|
||||
return 1
|
||||
}
|
||||
# Try to install intel-media-va-driver for newer GPUs
|
||||
$STD apt -y install intel-media-va-driver 2>/dev/null || true
|
||||
|
||||
elif [[ "$os_id" == "debian" ]]; then
|
||||
# Debian: Check version and install appropriate drivers
|
||||
if [[ "$needs_nonfree" == true ]]; then
|
||||
# Add non-free repo for intel-media-va-driver-non-free
|
||||
if [[ "$os_codename" == "bookworm" ]]; then
|
||||
# Debian 12 Bookworm
|
||||
if [[ ! -f /etc/apt/sources.list.d/non-free.list && ! -f /etc/apt/sources.list.d/non-free.sources ]]; then
|
||||
cat <<EOF >/etc/apt/sources.list.d/non-free.sources
|
||||
Types: deb
|
||||
URIs: http://deb.debian.org/debian
|
||||
Suites: bookworm bookworm-updates
|
||||
Components: non-free non-free-firmware
|
||||
EOF
|
||||
$STD apt update
|
||||
fi
|
||||
$STD apt -y install \
|
||||
intel-media-va-driver-non-free \
|
||||
ocl-icd-libopencl1 \
|
||||
intel-opencl-icd \
|
||||
vainfo \
|
||||
intel-gpu-tools || {
|
||||
msg_warn "Non-free driver install failed, falling back to open drivers"
|
||||
needs_nonfree=false
|
||||
}
|
||||
|
||||
elif [[ "$os_codename" == "trixie" || "$os_codename" == "sid" ]]; then
|
||||
# Debian 13 Trixie / Sid
|
||||
if [[ ! -f /etc/apt/sources.list.d/non-free.sources ]]; then
|
||||
cat <<'EOF' >/etc/apt/sources.list.d/non-free.sources
|
||||
Types: deb
|
||||
URIs: http://deb.debian.org/debian
|
||||
Suites: trixie trixie-updates
|
||||
Components: non-free non-free-firmware
|
||||
|
||||
Types: deb
|
||||
URIs: http://deb.debian.org/debian-security
|
||||
Suites: trixie-security
|
||||
Components: non-free non-free-firmware
|
||||
EOF
|
||||
$STD apt update
|
||||
fi
|
||||
$STD apt -y install \
|
||||
intel-media-va-driver-non-free \
|
||||
ocl-icd-libopencl1 \
|
||||
mesa-opencl-icd \
|
||||
mesa-va-drivers \
|
||||
libvpl2 \
|
||||
vainfo \
|
||||
intel-gpu-tools 2>/dev/null || {
|
||||
msg_warn "Non-free driver install failed, falling back to open drivers"
|
||||
needs_nonfree=false
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Fallback to open drivers or older Intel GPUs
|
||||
if [[ "$needs_nonfree" == false ]]; then
|
||||
# Fetch latest Intel drivers from GitHub for Debian
|
||||
fetch_and_deploy_gh_release "" "intel/intel-graphics-compiler" "binary" "latest" "" "intel-igc-core-2_*_amd64.deb" || {
|
||||
msg_warn "Failed to deploy Intel IGC core 2"
|
||||
}
|
||||
fetch_and_deploy_gh_release "" "intel/intel-graphics-compiler" "binary" "latest" "" "intel-igc-opencl-2_*_amd64.deb" || {
|
||||
msg_warn "Failed to deploy Intel IGC OpenCL 2"
|
||||
}
|
||||
fetch_and_deploy_gh_release "" "intel/compute-runtime" "binary" "latest" "" "libigdgmm12_*_amd64.deb" || {
|
||||
msg_warn "Failed to deploy Intel GDGMM12"
|
||||
}
|
||||
fetch_and_deploy_gh_release "" "intel/compute-runtime" "binary" "latest" "" "intel-opencl-icd_*_amd64.deb" || {
|
||||
msg_warn "Failed to deploy Intel OpenCL ICD"
|
||||
}
|
||||
|
||||
$STD apt -y install \
|
||||
va-driver-all \
|
||||
ocl-icd-libopencl1 \
|
||||
mesa-opencl-icd \
|
||||
mesa-va-drivers \
|
||||
vainfo \
|
||||
intel-gpu-tools || {
|
||||
msg_error "Failed to install Intel GPU dependencies"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
AMD)
|
||||
$STD apt -y install mesa-va-drivers mesa-vdpau-drivers mesa-opencl-icd vainfo clinfo || {
|
||||
$STD apt -y install \
|
||||
mesa-va-drivers \
|
||||
mesa-vdpau-drivers \
|
||||
mesa-opencl-icd \
|
||||
ocl-icd-libopencl1 \
|
||||
vainfo \
|
||||
clinfo 2>/dev/null || {
|
||||
msg_error "Failed to install AMD GPU dependencies"
|
||||
return 1
|
||||
}
|
||||
|
||||
# For AMD CPUs without discrete GPU (APUs)
|
||||
if [[ "$cpu_vendor" == "AuthenticAMD" && -n "$gpu_vendor" ]]; then
|
||||
$STD apt -y install libdrm-amdgpu1 firmware-amd-graphics || true
|
||||
# AMD firmware for better GPU support
|
||||
if [[ "$os_id" == "debian" ]]; then
|
||||
$STD apt -y install firmware-amd-graphics 2>/dev/null || true
|
||||
fi
|
||||
$STD apt -y install libdrm-amdgpu1 2>/dev/null || true
|
||||
;;
|
||||
|
||||
NVIDIA)
|
||||
# NVIDIA needs manual driver setup - skip for now
|
||||
msg_info "NVIDIA GPU detected - manual driver setup required"
|
||||
# NVIDIA needs manual driver setup or passthrough from host
|
||||
msg_warn "NVIDIA GPU detected - driver must be installed manually or passed through from host"
|
||||
# Install basic VA-API support for potential hybrid setups
|
||||
$STD apt -y install va-driver-all vainfo 2>/dev/null || true
|
||||
;;
|
||||
|
||||
*)
|
||||
# If no discrete GPU, but AMD CPU (e.g., Ryzen APU)
|
||||
# No discrete GPU detected - check for AMD APU
|
||||
if [[ "$cpu_vendor" == "AuthenticAMD" ]]; then
|
||||
$STD apt -y install mesa-opencl-icd ocl-icd-libopencl1 clinfo || {
|
||||
msg_error "Failed to install Mesa OpenCL stack"
|
||||
return 1
|
||||
}
|
||||
$STD apt -y install \
|
||||
mesa-va-drivers \
|
||||
mesa-vdpau-drivers \
|
||||
mesa-opencl-icd \
|
||||
ocl-icd-libopencl1 \
|
||||
vainfo 2>/dev/null || true
|
||||
else
|
||||
msg_warn "No supported GPU vendor detected - skipping GPU acceleration"
|
||||
msg_warn "No supported GPU vendor detected - skipping GPU driver installation"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$in_ct" == "0" ]]; then
|
||||
# Set permissions for /dev/dri (only in privileged containers and if /dev/dri exists)
|
||||
if [[ "$in_ct" == "0" && -d /dev/dri ]]; then
|
||||
chgrp video /dev/dri 2>/dev/null || true
|
||||
chmod 755 /dev/dri 2>/dev/null || true
|
||||
chmod 660 /dev/dri/* 2>/dev/null || true
|
||||
$STD adduser "$(id -u -n)" video
|
||||
$STD adduser "$(id -u -n)" render
|
||||
$STD adduser "$(id -u -n)" video 2>/dev/null || true
|
||||
$STD adduser "$(id -u -n)" render 2>/dev/null || true
|
||||
|
||||
# Sync GID for video/render groups between host and container
|
||||
local host_video_gid host_render_gid
|
||||
host_video_gid=$(getent group video | cut -d: -f3)
|
||||
host_render_gid=$(getent group render | cut -d: -f3)
|
||||
if [[ -n "$host_video_gid" && -n "$host_render_gid" ]]; then
|
||||
sed -i "s/^video:x:[0-9]*:/video:x:$host_video_gid:/" /etc/group 2>/dev/null || true
|
||||
sed -i "s/^render:x:[0-9]*:/render:x:$host_render_gid:/" /etc/group 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
|
||||
cache_installed_version "hwaccel" "1.0"
|
||||
|
||||
Reference in New Issue
Block a user