Automate VAAPI and NVIDIA setup inside LXC containers
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled
Added direct installation of VAAPI and NVIDIA drivers inside LXC containers during setup, removing reliance on custom in-container scripts. The process now ensures required packages are installed and user permissions are set, improving automation and compatibility for supported distributions.
This commit is contained in:
parent
d1258c02ac
commit
333ac1edcd
@ -2276,6 +2276,9 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
msg_info "Customizing LXC Container"
|
msg_info "Customizing LXC Container"
|
||||||
|
# Container erfolgreich gestartet
|
||||||
|
vaapi_inside_setup "$CTID" "$CT_TYPE"
|
||||||
|
nvidia_inside_setup "$CTID" "$CT_TYPE"
|
||||||
if [ "$var_os" == "alpine" ]; then
|
if [ "$var_os" == "alpine" ]; then
|
||||||
sleep 3
|
sleep 3
|
||||||
pct exec "$CTID" -- /bin/sh -c 'cat <<EOF >/etc/apk/repositories
|
pct exec "$CTID" -- /bin/sh -c 'cat <<EOF >/etc/apk/repositories
|
||||||
|
@ -181,28 +181,41 @@ vaapi_handle_passthrough() {
|
|||||||
local CTID="$1" CTTYPE="$2" APP="$3"
|
local CTID="$1" CTTYPE="$2" APP="$3"
|
||||||
|
|
||||||
local VAAPI_APPS=(immich Channels Emby ErsatzTV Frigate Jellyfin Plex Scrypted Tdarr Unmanic Ollama FileFlows "Open WebUI" Tunarr Debian)
|
local VAAPI_APPS=(immich Channels Emby ErsatzTV Frigate Jellyfin Plex Scrypted Tdarr Unmanic Ollama FileFlows "Open WebUI" Tunarr Debian)
|
||||||
local is_vaapi_app=false a
|
local is_vaapi_app=false
|
||||||
for a in "${VAAPI_APPS[@]}"; do [[ "$APP" == "$a" ]] && is_vaapi_app=true && break; done
|
for a in "${VAAPI_APPS[@]}"; do [[ "$APP" == "$a" ]] && is_vaapi_app=true && break; done
|
||||||
|
|
||||||
if [[ "$CTTYPE" == "0" || "$is_vaapi_app" == "true" ]]; then
|
if [[ "$CTTYPE" == "0" || "$is_vaapi_app" == "true" ]]; then
|
||||||
# 1. write config
|
|
||||||
vaapi_select_and_apply "$CTID" "$CTTYPE"
|
vaapi_select_and_apply "$CTID" "$CTTYPE"
|
||||||
|
|
||||||
# 2. ensure CT is running
|
# ensure CT is running
|
||||||
if ! pct status "$CTID" | grep -q "status: running"; then
|
if ! pct status "$CTID" | grep -q running; then
|
||||||
msg_info "Starting CT $CTID for VAAPI setup"
|
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
for i in {1..10}; do
|
for i in {1..10}; do
|
||||||
if pct status "$CTID" | grep -q "status: running"; then
|
pct status "$CTID" | grep -q running && break
|
||||||
msg_ok "CT $CTID is running"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3. run setup inside CT
|
# run apt install directly inside CT
|
||||||
pct exec "$CTID" -- bash -lc "_hwaccel_setup_in_ct '$CTTYPE'"
|
pct exec "$CTID" -- bash -lc '
|
||||||
|
. /etc/os-release
|
||||||
|
case "$VERSION_CODENAME" in
|
||||||
|
trixie|noble)
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y intel-media-va-driver-non-free ocl-icd-libopencl1 \
|
||||||
|
mesa-opencl-icd mesa-va-drivers libvpl2 vainfo intel-gpu-tools
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y va-driver-all ocl-icd-libopencl1 \
|
||||||
|
mesa-opencl-icd mesa-va-drivers vainfo intel-gpu-tools
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [[ "'"$CTTYPE"'" == "0" ]]; then
|
||||||
|
adduser "$(id -un)" video || true
|
||||||
|
adduser "$(id -un)" render || true
|
||||||
|
fi
|
||||||
|
'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,32 +251,29 @@ nvidia_passthrough_to_lxc() {
|
|||||||
nvidia_handle_passthrough() {
|
nvidia_handle_passthrough() {
|
||||||
local CTID="$1" CTTYPE="$2" APP="$3"
|
local CTID="$1" CTTYPE="$2" APP="$3"
|
||||||
|
|
||||||
# Only offer if NVIDIA devices exist on host
|
|
||||||
compgen -G "/dev/nvidia*" >/dev/null || return 0
|
compgen -G "/dev/nvidia*" >/dev/null || return 0
|
||||||
|
|
||||||
if whiptail --title "NVIDIA passthrough" \
|
if whiptail --title "NVIDIA passthrough" \
|
||||||
--yesno "NVIDIA GPU detected on host.\n\nMap /dev/nvidia* into CT ${CTID} and install NVIDIA userland inside the container?" 12 70; then
|
--yesno "NVIDIA GPU detected. Map /dev/nvidia* into CT $CTID and install drivers inside?" 12 70; then
|
||||||
|
|
||||||
# 1. Host: map devices into LXC config
|
|
||||||
nvidia_passthrough_to_lxc "$CTID" "$CTTYPE"
|
nvidia_passthrough_to_lxc "$CTID" "$CTTYPE"
|
||||||
|
|
||||||
# 2. CT must be running before pct exec
|
if ! pct status "$CTID" | grep -q running; then
|
||||||
if ! pct status "$CTID" | grep -q "status: running"; then
|
|
||||||
msg_info "Starting CT $CTID for NVIDIA setup"
|
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
for i in {1..10}; do
|
for i in {1..10}; do
|
||||||
if pct status "$CTID" | grep -q "status: running"; then
|
pct status "$CTID" | grep -q running && break
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3. Run NVIDIA setup inside CT
|
pct exec "$CTID" -- bash -lc '
|
||||||
pct exec "$CTID" -- bash -lc "_nvidia_setup_in_ct '$CTTYPE'"
|
. /etc/os-release
|
||||||
|
apt-get update
|
||||||
else
|
apt-get install -y nvidia-driver nvidia-utils libnvidia-encode1 libcuda1
|
||||||
msg_warn "Skipped NVIDIA passthrough by user choice."
|
if [[ "'"$CTTYPE"'" == "0" ]]; then
|
||||||
|
adduser "$(id -un)" video || true
|
||||||
|
fi
|
||||||
|
'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user