From e1a1b57bb563ced2d3b450afabb533f3a9d02120 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sat, 2 Mar 2024 09:44:58 +0100 Subject: [PATCH] feat(entrypoint): detect GPU Signed-off-by: Ettore Di Giacinto --- entrypoint.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 05f671284ff1..c7e5310dd99b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -47,4 +47,30 @@ else echo "@@@@@" fi +GPU_ACCELERATION=false +case "$(uname -s)" in + Linux) + if lspci | grep -E 'VGA|3D' | grep -iq nvidia; then + echo "NVIDIA GPU detected" + GPU_ACCELERATION=true + elif lspci | grep -E 'VGA|3D' | grep -iq amd; then + echo "AMD GPU detected" + GPU_ACCELERATION=true + elif lspci | grep -E 'VGA|3D' | grep -iq intel; then + echo "Intel GPU detected" + GPU_ACCELERATION=true + fi + ;; + Darwin) + if system_profiler SPDisplaysDataType | grep -iq 'Metal'; then + echo "Apple Metal supported GPU detected" + GPU_ACCELERATION=true + fi + ;; +esac + +if [ "$GPU_ACCELERATION" = "false" ]; then + echo "!!! No GPU detected, running with CPU only !!!" +fi + ./local-ai "$@"