Fix NVIDIA passthrough logic in container build
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
Refactored the NVIDIA GPU passthrough configuration to ensure device entries and related settings are only added when /dev/nvidia* devices are present. This prevents passthrough configuration attempts when no NVIDIA devices are detected, improving reliability and error messaging.
This commit is contained in:
parent
2d0b42ae45
commit
e7936a686a
@ -2198,6 +2198,7 @@ build_container() {
|
|||||||
msg_info "Fix NVIDIA drivers on host, then recreate container or passthrough manually."
|
msg_info "Fix NVIDIA drivers on host, then recreate container or passthrough manually."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for d in /dev/nvidia* /dev/nvidiactl /dev/nvidia-modeset; do
|
for d in /dev/nvidia* /dev/nvidiactl /dev/nvidia-modeset; do
|
||||||
[[ -e "$d" ]] && NVIDIA_DEVICES+=("$d")
|
[[ -e "$d" ]] && NVIDIA_DEVICES+=("$d")
|
||||||
done
|
done
|
||||||
@ -2205,7 +2206,7 @@ build_container() {
|
|||||||
if [[ ${#NVIDIA_DEVICES[@]} -eq 0 ]]; then
|
if [[ ${#NVIDIA_DEVICES[@]} -eq 0 ]]; then
|
||||||
msg_warn "NVIDIA GPU detected but no /dev/nvidia* devices found"
|
msg_warn "NVIDIA GPU detected but no /dev/nvidia* devices found"
|
||||||
msg_warn "Please install NVIDIA drivers on host: apt install nvidia-driver"
|
msg_warn "Please install NVIDIA drivers on host: apt install nvidia-driver"
|
||||||
fi
|
else
|
||||||
if [[ "$CT_TYPE" == "0" ]]; then
|
if [[ "$CT_TYPE" == "0" ]]; then
|
||||||
cat <<EOF >>"$LXC_CONFIG"
|
cat <<EOF >>"$LXC_CONFIG"
|
||||||
# NVIDIA GPU Passthrough (privileged)
|
# NVIDIA GPU Passthrough (privileged)
|
||||||
@ -2215,8 +2216,8 @@ build_container() {
|
|||||||
lxc.mount.entry: /dev/nvidiactl dev/nvidiactl none bind,optional,create=file
|
lxc.mount.entry: /dev/nvidiactl dev/nvidiactl none bind,optional,create=file
|
||||||
lxc.mount.entry: /dev/nvidia-uvm dev/nvidia-uvm none bind,optional,create=file
|
lxc.mount.entry: /dev/nvidia-uvm dev/nvidia-uvm none bind,optional,create=file
|
||||||
lxc.mount.entry: /dev/nvidia-uvm-tools dev/nvidia-uvm-tools none bind,optional,create=file
|
lxc.mount.entry: /dev/nvidia-uvm-tools dev/nvidia-uvm-tools none bind,optional,create=file
|
||||||
EOF
|
EOF
|
||||||
fi
|
|
||||||
if [[ -e /dev/dri/renderD128 ]]; then
|
if [[ -e /dev/dri/renderD128 ]]; then
|
||||||
echo "lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file" >>"$LXC_CONFIG"
|
echo "lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file" >>"$LXC_CONFIG"
|
||||||
fi
|
fi
|
||||||
@ -2229,7 +2230,7 @@ build_container() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
fi
|
||||||
|
|
||||||
# Debug output
|
# Debug output
|
||||||
msg_debug "Intel devices: ${INTEL_DEVICES[*]}"
|
msg_debug "Intel devices: ${INTEL_DEVICES[*]}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user