Преглед изворни кода

fix nvidia detection in install script (#4683)

Jeffrey Morgan пре 11 месеци
родитељ
комит
b7d316d98d
1 измењених фајлова са 14 додато и 9 уклоњено
  1. 14 9
      scripts/install.sh

+ 14 - 9
scripts/install.sh

@@ -153,6 +153,11 @@ check_gpu() {
     esac
     esac
 }
 }
 
 
+if check_gpu nvidia-smi; then
+    status "NVIDIA GPU installed."
+    exit 0
+fi
+
 if ! check_gpu lspci nvidia && ! check_gpu lshw nvidia && ! check_gpu lspci amdgpu && ! check_gpu lshw amdgpu; then
 if ! check_gpu lspci nvidia && ! check_gpu lshw nvidia && ! check_gpu lspci amdgpu && ! check_gpu lshw amdgpu; then
     install_success
     install_success
     warning "No NVIDIA/AMD GPU detected. Ollama will run in CPU-only mode."
     warning "No NVIDIA/AMD GPU detected. Ollama will run in CPU-only mode."
@@ -269,7 +274,7 @@ if ! check_gpu nvidia-smi || [ -z "$(nvidia-smi | grep -o "CUDA Version: [0-9]*\
     esac
     esac
 fi
 fi
 
 
-if ! lsmod | grep -q nvidia; then
+if ! lsmod | grep -q nvidia || ! lsmod | grep -q nvidia_uvm; then
     KERNEL_RELEASE="$(uname -r)"
     KERNEL_RELEASE="$(uname -r)"
     case $OS_NAME in
     case $OS_NAME in
         rocky) $SUDO $PACKAGE_MANAGER -y install kernel-devel kernel-headers ;;
         rocky) $SUDO $PACKAGE_MANAGER -y install kernel-devel kernel-headers ;;
@@ -283,10 +288,15 @@ if ! lsmod | grep -q nvidia; then
     if [ -n "$NVIDIA_CUDA_VERSION" ]; then
     if [ -n "$NVIDIA_CUDA_VERSION" ]; then
         $SUDO dkms install $NVIDIA_CUDA_VERSION
         $SUDO dkms install $NVIDIA_CUDA_VERSION
     fi
     fi
-fi
 
 
-$SUDO modprobe nvidia
-$SUDO modprobe nvidia_uvm
+    if lsmod | grep -q nouveau; then
+        status 'Reboot to complete NVIDIA CUDA driver install.'
+        exit 0
+    fi
+
+    $SUDO modprobe nvidia
+    $SUDO modprobe nvidia_uvm
+fi
 
 
 # make sure the NVIDIA modules are loaded on boot with nvidia-persistenced
 # make sure the NVIDIA modules are loaded on boot with nvidia-persistenced
 if command -v nvidia-persistenced > /dev/null 2>&1; then
 if command -v nvidia-persistenced > /dev/null 2>&1; then
@@ -299,9 +309,4 @@ if command -v nvidia-persistenced > /dev/null 2>&1; then
     done
     done
 fi
 fi
 
 
-if lsmod | grep -q nouveau; then
-    status 'Reboot to complete NVIDIA CUDA driver install.'
-    exit 0
-fi
-
 status "NVIDIA GPU ready."
 status "NVIDIA GPU ready."