NVIDIA GPU detection support for WSL2 environments (#1891)

This change makes the assumption that "Microsoft Corporation Device 008e"
is an NVIDIA CUDA device. If this is not the case, please update the
hardware detection script here.

Signed-off-by: Enrico Ros <enrico.ros@gmail.com>
Co-authored-by: Dave <dave@gray101.com>
This commit is contained in:
Enrico Ros 2024-03-25 00:32:40 -07:00 committed by GitHub
parent 6cf99527f8
commit 5e12382524
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,6 +33,17 @@ function detect_gpu() {
else else
echo "Intel GPU detected, but Intel GPU drivers are not installed. GPU acceleration will not be available." echo "Intel GPU detected, but Intel GPU drivers are not installed. GPU acceleration will not be available."
fi fi
elif lspci | grep -E 'VGA|3D' | grep -iq "Microsoft Corporation Device 008e"; then
# We make the assumption this WSL2 cars is NVIDIA, then check for nvidia-smi
# Make sure the container was run with `--gpus all` as the only required parameter
echo "NVIDIA GPU detected via WSL2"
# nvidia-smi should be installed in the container
if nvidia-smi; then
GPU_ACCELERATION=true
GPU_VENDOR=nvidia
else
echo "NVIDIA GPU detected via WSL2, but nvidia-smi is not installed. GPU acceleration will not be available."
fi
fi fi
;; ;;
Darwin) Darwin)
@ -95,4 +106,4 @@ check_vars
echo "Starting LocalAI with the following models: $MODELS" echo "Starting LocalAI with the following models: $MODELS"
/build/entrypoint.sh "$@" /build/entrypoint.sh "$@"