Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More sanity checks for comp_and_load_drivers.sh #140

Merged
merged 1 commit into from
May 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions data_gpu/driver/comp_and_load_drivers.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
#!/bin/bash

# Provide defaults for CC
[ -z "$CC" ] && CC=gcc

# Function to check if the script is run with sudo
check_sudo() {
if [ "$EUID" -ne 0 ]; then
echo "Error: This script must be run with sudo." >&2
exit 1
fi
}

# Function to check if gcc-12 is installed
check_gcc_12_installed() {
if ! command -v gcc-12 >/dev/null 2>&1; then
echo "Error: gcc-12 is not installed. Please install gcc-12 and try again." >&2
# Checks that GCC matches what the kernel was built with
check_gcc_version() {
_GCC_VER="$($CC --version | grep -Eo "\s[0-9]+\.[0-9]+\.[0-9]+\s" | awk '{$1=$1};1')"
if ! cat /proc/version | grep -Eoq "gcc version $_GCC_VER"; then
echo "Error: GCC version 'gcc version $_GCC_VER' does not match what the kernel was built with: '$(cat /proc/version | grep -Eo "gcc version [0-9]+\.[0-9]+\.[0-9]+")'"
echo " You can specify an alternative compiler by setting the 'CC' environment variable"
exit 1
fi
}

# Check if the script is run with sudo
check_sudo

# Call the gcc-12 check function early in the script to ensure it's available
check_gcc_12_installed
# Check that our GCC matches what the kernel was built with
check_gcc_version

# Function to find the latest Nvidia version directory
get_latest_nvidia_path() {
Expand Down Expand Up @@ -57,9 +61,11 @@ echo "Using Nvidia path: $NVIDIA_PATH"

cd $NVIDIA_PATH

make CC=gcc-12
make

modprobe ecc || { echo "Error: Failed to insert ecc module."; exit 1; }
if modinfo ecc >/dev/null 2>&1; then
modprobe ecc || { echo "Error: Failed to insert ecc module."; exit 1; }
fi

/usr/sbin/insmod nvidia.ko NVreg_OpenRmEnableUnsupportedGpus=1 NVreg_EnableStreamMemOPs=1 || { echo "Error: Failed to insert nvidia.ko."; exit 1; }

Expand Down