Improve NVIDIA device detection for container passthrough (#9670)

This commit is contained in:
CanbiZ 2025-12-05 12:44:23 +01:00 committed by GitHub
parent 316082eaaa
commit d2e9997d0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2442,9 +2442,16 @@ build_container() {
msg_custom "🎮" "${GN}" "Detected NVIDIA GPU" msg_custom "🎮" "${GN}" "Detected NVIDIA GPU"
# Simple passthrough - just bind /dev/nvidia* devices if they exist # Simple passthrough - just bind /dev/nvidia* devices if they exist
for d in /dev/nvidia* /dev/nvidiactl /dev/nvidia-modeset /dev/nvidia-uvm /dev/nvidia-uvm-tools; do # Only include character devices (-c), skip directories like /dev/nvidia-caps
[[ -e "$d" ]] && NVIDIA_DEVICES+=("$d") for d in /dev/nvidia*; do
[[ -c "$d" ]] && NVIDIA_DEVICES+=("$d")
done done
# Also check for devices inside /dev/nvidia-caps/ directory
if [[ -d /dev/nvidia-caps ]]; then
for d in /dev/nvidia-caps/*; do
[[ -c "$d" ]] && NVIDIA_DEVICES+=("$d")
done
fi
if [[ ${#NVIDIA_DEVICES[@]} -gt 0 ]]; then if [[ ${#NVIDIA_DEVICES[@]} -gt 0 ]]; then
msg_custom "🎮" "${GN}" "Found ${#NVIDIA_DEVICES[@]} NVIDIA device(s) for passthrough" msg_custom "🎮" "${GN}" "Found ${#NVIDIA_DEVICES[@]} NVIDIA device(s) for passthrough"