merge tools.func from VE to VED
This commit is contained in:
parent
f680e24aef
commit
db5e26f4f1
127
misc/tools.func
127
misc/tools.func
@ -2691,7 +2691,7 @@ function setup_hwaccel() {
|
||||
else
|
||||
# Multiple GPUs - show selection menu
|
||||
echo ""
|
||||
msg_info "Multiple GPUs detected:"
|
||||
msg_custom "⚠" "${YW}" "Multiple GPUs detected:"
|
||||
echo ""
|
||||
for i in "${!GPU_LIST[@]}"; do
|
||||
local type_display="${GPU_TYPES[$i]}"
|
||||
@ -3010,16 +3010,24 @@ _setup_nvidia_gpu() {
|
||||
|
||||
msg_info "Installing NVIDIA GPU drivers"
|
||||
|
||||
# Prevent interactive dialogs (e.g., "Mismatching nvidia kernel module" whiptail)
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
export NEEDRESTART_MODE=a
|
||||
|
||||
# Detect host driver version (passed through via /proc)
|
||||
# Format varies by driver type:
|
||||
# Proprietary: "NVRM version: NVIDIA UNIX x86_64 Kernel Module 550.54.14 Thu..."
|
||||
# Open: "NVRM version: NVIDIA UNIX Open Kernel Module for x86_64 590.48.01 Release..."
|
||||
# Use regex to extract version number (###.##.## pattern)
|
||||
local nvidia_host_version=""
|
||||
if [[ -f /proc/driver/nvidia/version ]]; then
|
||||
nvidia_host_version=$(grep "NVRM version:" /proc/driver/nvidia/version 2>/dev/null | awk '{print $8}')
|
||||
nvidia_host_version=$(grep -oP '\d{3,}\.\d+\.\d+' /proc/driver/nvidia/version 2>/dev/null | head -1)
|
||||
fi
|
||||
|
||||
if [[ -z "$nvidia_host_version" ]]; then
|
||||
msg_warn "NVIDIA host driver version not found in /proc/driver/nvidia/version"
|
||||
msg_warn "Ensure NVIDIA drivers are installed on host and GPU passthrough is enabled"
|
||||
$STD apt -y install va-driver-all vainfo 2>/dev/null || true
|
||||
$STD apt-get -y install va-driver-all vainfo 2>/dev/null || true
|
||||
return 0
|
||||
fi
|
||||
|
||||
@ -3032,13 +3040,53 @@ _setup_nvidia_gpu() {
|
||||
sed -i -E 's/Components: (.*)$/Components: \1 contrib non-free non-free-firmware/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
$STD apt-get -y update 2>/dev/null || msg_warn "apt update failed - continuing anyway"
|
||||
|
||||
# Determine CUDA repository
|
||||
# For Debian 13 Trixie/Sid: Use Debian's own nvidia packages first (better compatibility)
|
||||
# NVIDIA's CUDA repo targets Debian 12 and may not have amd64 packages for Trixie
|
||||
if [[ "$os_codename" == "trixie" || "$os_codename" == "sid" ]]; then
|
||||
msg_info "Debian ${os_codename}: Using Debian's NVIDIA packages"
|
||||
|
||||
# Extract major version for flexible matching (580.126.09 -> 580)
|
||||
local nvidia_major_version="${nvidia_host_version%%.*}"
|
||||
|
||||
# Check what versions are actually available
|
||||
local available_version=""
|
||||
available_version=$(apt-cache madison libcuda1 2>/dev/null | awk '{print $3}' | grep -E "^${nvidia_major_version}\." | head -1 || true)
|
||||
|
||||
if [[ -n "$available_version" ]]; then
|
||||
msg_info "Found available NVIDIA version: ${available_version}"
|
||||
local nvidia_pkgs="libcuda1=${available_version} libnvcuvid1=${available_version} libnvidia-encode1=${available_version} libnvidia-ml1=${available_version}"
|
||||
if $STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends $nvidia_pkgs 2>/dev/null; then
|
||||
msg_ok "Installed NVIDIA libraries (${available_version})"
|
||||
else
|
||||
msg_warn "Failed to install NVIDIA ${available_version} - trying unversioned"
|
||||
$STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends libcuda1 libnvcuvid1 libnvidia-encode1 libnvidia-ml1 2>/dev/null || true
|
||||
fi
|
||||
else
|
||||
# No matching major version - try latest available or unversioned
|
||||
msg_warn "No NVIDIA packages for version ${nvidia_major_version}.x found in repos"
|
||||
available_version=$(apt-cache madison libcuda1 2>/dev/null | awk '{print $3}' | head -1 || true)
|
||||
if [[ -n "$available_version" ]]; then
|
||||
msg_info "Trying latest available: ${available_version} (may cause version mismatch)"
|
||||
$STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends \
|
||||
libcuda1="${available_version}" libnvcuvid1="${available_version}" \
|
||||
libnvidia-encode1="${available_version}" libnvidia-ml1="${available_version}" 2>/dev/null ||
|
||||
$STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends \
|
||||
libcuda1 libnvcuvid1 libnvidia-encode1 libnvidia-ml1 2>/dev/null ||
|
||||
msg_warn "NVIDIA library installation failed - GPU compute may not work"
|
||||
else
|
||||
msg_warn "No NVIDIA packages available in Debian repos - GPU support disabled"
|
||||
fi
|
||||
fi
|
||||
$STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends nvidia-smi 2>/dev/null || true
|
||||
|
||||
else
|
||||
# Debian 11/12: Use NVIDIA CUDA repository for version matching
|
||||
local cuda_repo="debian12"
|
||||
case "$os_codename" in
|
||||
bullseye) cuda_repo="debian11" ;;
|
||||
bookworm) cuda_repo="debian12" ;;
|
||||
trixie | sid) cuda_repo="debian12" ;; # Forward compatible
|
||||
esac
|
||||
|
||||
# Add NVIDIA CUDA repository
|
||||
@ -3061,24 +3109,46 @@ Pin: origin developer.download.nvidia.com
|
||||
Pin-Priority: 1001
|
||||
NVIDIA_PIN
|
||||
|
||||
$STD apt -y update
|
||||
$STD apt-get -y update 2>/dev/null || msg_warn "apt update failed - continuing anyway"
|
||||
|
||||
# Install version-matched NVIDIA libraries
|
||||
local nvidia_pkgs="libcuda1=${nvidia_host_version}* libnvcuvid1=${nvidia_host_version}* libnvidia-encode1=${nvidia_host_version}* libnvidia-ml1=${nvidia_host_version}*"
|
||||
# Extract major version for flexible matching (580.126.09 -> 580)
|
||||
local nvidia_major_version="${nvidia_host_version%%.*}"
|
||||
|
||||
msg_info "Installing NVIDIA libraries (version ${nvidia_host_version})"
|
||||
if $STD apt -y install --no-install-recommends $nvidia_pkgs 2>/dev/null; then
|
||||
# Check what versions are actually available in CUDA repo
|
||||
local available_version=""
|
||||
available_version=$(apt-cache madison libcuda1 2>/dev/null | awk '{print $3}' | grep -E "^${nvidia_major_version}\." | head -1 || true)
|
||||
|
||||
if [[ -n "$available_version" ]]; then
|
||||
msg_info "Installing NVIDIA libraries (version ${available_version})"
|
||||
local nvidia_pkgs="libcuda1=${available_version} libnvcuvid1=${available_version} libnvidia-encode1=${available_version} libnvidia-ml1=${available_version}"
|
||||
if $STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends $nvidia_pkgs 2>/dev/null; then
|
||||
msg_ok "Installed version-matched NVIDIA libraries"
|
||||
else
|
||||
msg_warn "Version-pinned install failed - trying unpinned"
|
||||
if $STD apt -y install --no-install-recommends libcuda1 libnvcuvid1 libnvidia-encode1 libnvidia-ml1 2>/dev/null; then
|
||||
msg_warn "Installed NVIDIA libraries (unpinned) - version mismatch may occur"
|
||||
else
|
||||
$STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends libcuda1 libnvcuvid1 libnvidia-encode1 libnvidia-ml1 2>/dev/null ||
|
||||
msg_warn "NVIDIA library installation failed"
|
||||
fi
|
||||
else
|
||||
msg_warn "No NVIDIA packages for version ${nvidia_major_version}.x in CUDA repo (host: ${nvidia_host_version})"
|
||||
# Try latest available version
|
||||
available_version=$(apt-cache madison libcuda1 2>/dev/null | awk '{print $3}' | head -1 || true)
|
||||
if [[ -n "$available_version" ]]; then
|
||||
msg_info "Trying latest available: ${available_version} (version mismatch warning)"
|
||||
if $STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends \
|
||||
libcuda1="${available_version}" libnvcuvid1="${available_version}" \
|
||||
libnvidia-encode1="${available_version}" libnvidia-ml1="${available_version}" 2>/dev/null; then
|
||||
msg_ok "Installed NVIDIA libraries (${available_version}) - version differs from host"
|
||||
else
|
||||
$STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends libcuda1 libnvcuvid1 libnvidia-encode1 libnvidia-ml1 2>/dev/null ||
|
||||
msg_warn "NVIDIA library installation failed"
|
||||
fi
|
||||
else
|
||||
msg_warn "No NVIDIA packages available in CUDA repo - GPU support disabled"
|
||||
fi
|
||||
fi
|
||||
|
||||
$STD apt -y install --no-install-recommends nvidia-smi 2>/dev/null || true
|
||||
$STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends nvidia-smi 2>/dev/null || true
|
||||
fi
|
||||
|
||||
elif [[ "$os_id" == "ubuntu" ]]; then
|
||||
# Ubuntu versioning
|
||||
@ -3102,20 +3172,33 @@ NVIDIA_PIN
|
||||
rm -f "$cuda_keyring"
|
||||
fi
|
||||
|
||||
$STD apt -y update
|
||||
$STD apt-get -y update 2>/dev/null || msg_warn "apt update failed - continuing anyway"
|
||||
|
||||
# Try version-matched install
|
||||
local nvidia_pkgs="libcuda1=${nvidia_host_version}* libnvcuvid1=${nvidia_host_version}* libnvidia-encode1=${nvidia_host_version}* libnvidia-ml1=${nvidia_host_version}*"
|
||||
if $STD apt -y install --no-install-recommends $nvidia_pkgs 2>/dev/null; then
|
||||
# Extract major version for flexible matching
|
||||
local nvidia_major_version="${nvidia_host_version%%.*}"
|
||||
|
||||
# Check what versions are available
|
||||
local available_version=""
|
||||
available_version=$(apt-cache madison libcuda1 2>/dev/null | awk '{print $3}' | grep -E "^${nvidia_major_version}\." | head -1 || true)
|
||||
|
||||
if [[ -n "$available_version" ]]; then
|
||||
msg_info "Installing NVIDIA libraries (version ${available_version})"
|
||||
local nvidia_pkgs="libcuda1=${available_version} libnvcuvid1=${available_version} libnvidia-encode1=${available_version} libnvidia-ml1=${available_version}"
|
||||
if $STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends $nvidia_pkgs 2>/dev/null; then
|
||||
msg_ok "Installed version-matched NVIDIA libraries"
|
||||
else
|
||||
# Fallback to Ubuntu repo packages
|
||||
$STD apt -y install --no-install-recommends libnvidia-decode libnvidia-encode nvidia-utils 2>/dev/null || msg_warn "NVIDIA installation failed"
|
||||
$STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends libnvidia-decode libnvidia-encode nvidia-utils 2>/dev/null || msg_warn "NVIDIA installation failed"
|
||||
fi
|
||||
else
|
||||
msg_warn "No NVIDIA packages for version ${nvidia_major_version}.x in CUDA repo"
|
||||
# Fallback to Ubuntu repo packages
|
||||
$STD apt-get -y -o Dpkg::Options::="--force-confold" install --no-install-recommends libnvidia-decode libnvidia-encode nvidia-utils 2>/dev/null || msg_warn "NVIDIA installation failed"
|
||||
fi
|
||||
fi
|
||||
|
||||
# VA-API for hybrid setups (Intel + NVIDIA)
|
||||
$STD apt -y install va-driver-all vainfo 2>/dev/null || true
|
||||
$STD apt-get -y install va-driver-all vainfo 2>/dev/null || true
|
||||
|
||||
msg_ok "NVIDIA GPU configured"
|
||||
}
|
||||
@ -3215,6 +3298,10 @@ EOF
|
||||
$STD apt -y update
|
||||
}
|
||||
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
# Helper: Setup GPU device permissions
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
# Helper: Setup GPU device permissions
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user