From 5e1238252458a548cba197f7c1e88fac44d6f3e7 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Mon, 25 Mar 2024 00:32:40 -0700 Subject: [PATCH] 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 Co-authored-by: Dave --- aio/entrypoint.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/aio/entrypoint.sh b/aio/entrypoint.sh index b2f64f63..aeb5e4de 100755 --- a/aio/entrypoint.sh +++ b/aio/entrypoint.sh @@ -33,6 +33,17 @@ function detect_gpu() { else echo "Intel GPU detected, but Intel GPU drivers are not installed. GPU acceleration will not be available." 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 ;; Darwin) @@ -95,4 +106,4 @@ check_vars echo "Starting LocalAI with the following models: $MODELS" -/build/entrypoint.sh "$@" \ No newline at end of file +/build/entrypoint.sh "$@"