diff --git a/misc/hw-acceleration.sh b/misc/hw-acceleration.sh index 0806bdfa..37ba817e 100644 --- a/misc/hw-acceleration.sh +++ b/misc/hw-acceleration.sh @@ -5,7 +5,7 @@ # License: MIT # https://github.com/tteck/Proxmox/raw/main/LICENSE -set -eEuo pipefail +set -e function header_info { clear cat <<"EOF" @@ -19,7 +19,7 @@ EOF } header_info echo "Loading..." -whiptail --backtitle "Proxmox VE Helper Scripts" --title "Add HW Acceleration" --yesno "This Will Add HW Acceleration to an existing LXC Container. Proceed?" 10 68 || exit +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Add Intel HW Acceleration" --yesno "This Will Add Intel HW Acceleration to an existing LXC Container. Proceed?" 8 72 || exit NODE=$(hostname) PREV_MENU=() MSG_MAX_LENGTH=0 @@ -33,7 +33,7 @@ while read -r TAG ITEM; do ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET PREV_MENU+=("$TAG" "$ITEM " "OFF") done < <(echo "$privileged_containers") -privileged_container=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Privileged Containers on $NODE" --checklist "\nSelect a Container To Add HW Acceleration:\n" 16 $((MSG_MAX_LENGTH + 23)) 6 "${PREV_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit +privileged_container=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Privileged Containers on $NODE" --checklist "\nSelect a Container To Add Intel HW Acceleration:\n" 16 $((MSG_MAX_LENGTH + 23)) 6 "${PREV_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit header_info cat <>/etc/pve/lxc/${privileged_container}.conf lxc.cgroup2.devices.allow: c 226:0 rwm @@ -43,7 +43,27 @@ lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file EOF -pct exec $privileged_container -- bash -c "apt-get -y install va-driver-all && apt-get -y install ocl-icd-libopencl1 && apt-get install -y intel-opencl-icd && chgrp video /dev/dri && chmod 755 /dev/dri && chmod 660 /dev/dri/* && adduser \$(id -u -n) video && adduser \$(id -u -n) render" +read -r -p "Do you need the intel-media-va-driver-non-free driver (Sources change)? " prompt +if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + header_info + pct exec ${privileged_container} -- bash -c "cat </etc/apt/sources.list + +deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware +deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware + +deb http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware +deb-src http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware + +deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware +deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware +EOF" + + pct exec ${privileged_container} -- bash -c "apt-get update && apt-get install -y intel-media-va-driver-non-free ocl-icd-libopencl1 intel-opencl-icd vainfo intel-gpu-tools && chgrp video /dev/dri && chmod 755 /dev/dri && adduser \$(id -u -n) video && adduser \$(id -u -n) render" +else + header_info + pct exec ${privileged_container} -- bash -c "apt-get install -y va-driver-all ocl-icd-libopencl1 intel-opencl-icd vainfo intel-gpu-tools && chgrp video /dev/dri && chmod 755 /dev/dri && adduser \$(id -u -n) video && adduser \$(id -u -n) render" +fi +whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Added tools" "vainfo, execute command 'vainfo'\nintel-gpu-tools, execute command 'intel_gpu_top'" 8 58 header_info echo -e "Completed Successfully!\n" echo -e "Reboot container $privileged_container to apply the new settings\n"