fix nvidia detection in install script (#4683)

This commit is contained in:
Jeffrey Morgan 2024-05-28 09:59:36 -07:00 committed by GitHub
parent d7339fad52
commit b7d316d98d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -153,6 +153,11 @@ check_gpu() {
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
install_success
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
fi
if ! lsmod | grep -q nvidia; then
if ! lsmod | grep -q nvidia || ! lsmod | grep -q nvidia_uvm; then
KERNEL_RELEASE="$(uname -r)"
case $OS_NAME in
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
$SUDO dkms install $NVIDIA_CUDA_VERSION
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
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
fi
if lsmod | grep -q nouveau; then
status 'Reboot to complete NVIDIA CUDA driver install.'
exit 0
fi
status "NVIDIA GPU ready."