From 5289c2b185360a2fadccf5f619139e3c4f28ccb3 Mon Sep 17 00:00:00 2001 From: liulinghui Date: Mon, 26 Nov 2018 10:41:08 +0800 Subject: [PATCH 1/2] Fix the case that installed kernel-devel till the patch number is matched --- nvidia-gpu-installer.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/nvidia-gpu-installer.sh b/nvidia-gpu-installer.sh index 156d3a5..9859c7e 100755 --- a/nvidia-gpu-installer.sh +++ b/nvidia-gpu-installer.sh @@ -198,12 +198,18 @@ install_devel_centos() yum update -y yum install -y kernel-devel kernel-headers if [ ! -d $kernel_dir ] ; then - # ln -s $(ls /usr/src/kernels | head -n1) $kernel_dir - echo "kernel development not found for $KERNEL_VERSION" - echo "RUN this command below to upgrade your kernel:" - echo " yum update -y && yum install -y kernel-devel kernel-headers" - echo "And then reboot!" - exit 1 + installed_version=$(rpm -q kernel-devel | sed s/kernel-devel-//) + echo "kernel development not found for $KERNEL_VERSION, found: $installed_version" + if test $(echo $installed_version | cut -d. -f1,2,3) = $(echo $KERNEL_VERSION | cut -d. -f1,2,3); then + echo "But the kernel version until the patch number is same." + echo "So try to use /usr/src/kernels/$installed_version as the kernel dir anyway." + ln -s /usr/src/kernels/$installed_version $kernel_dir + else + echo "RUN this command below to upgrade your kernel:" + echo " yum update -y && yum install -y kernel-devel kernel-headers" + echo "And then reboot!" + exit 1 + fi fi else mkdir -p /usr/src/kernels From 784697dfb72246e22752ba84d9a61863ac58870d Mon Sep 17 00:00:00 2001 From: liulinghui Date: Mon, 26 Nov 2018 10:46:40 +0800 Subject: [PATCH 2/2] Add redhat support --- nvidia-gpu-installer.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nvidia-gpu-installer.sh b/nvidia-gpu-installer.sh index 9859c7e..3a79aa5 100755 --- a/nvidia-gpu-installer.sh +++ b/nvidia-gpu-installer.sh @@ -17,6 +17,12 @@ NVIDIA_DRIVER_VERSION="${NVIDIA_DRIVER_VERSION:-384.111}" get_release() { eval "$(sed 's/^[A-Za-z]/OS_&/' /etc/os-release)" + if test $OS_ID = rhel; then + # translate redhat into centos + OS_ID=centos + # get the major number of OS_VERSION_ID + OS_VERSION_ID=$(echo $OS_VERSION_ID | cut -d. -f1) + fi } pre_check()