From 59c0654397345970d59ed037c70e38a8e0f3393b Mon Sep 17 00:00:00 2001 From: Jeremy Lorelli Date: Thu, 17 Oct 2024 16:08:36 -0700 Subject: [PATCH] Adjust dkms configuration to support building datagpu against nvidia drivers --- data_gpu/driver/Makefile | 9 +++++++- data_gpu/driver/build-nvidia.sh | 41 +++++++++++++++++++++++++++++++++ data_gpu/driver/dkms.conf | 7 ++++-- 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100755 data_gpu/driver/build-nvidia.sh diff --git a/data_gpu/driver/Makefile b/data_gpu/driver/Makefile index 37c954c..94be4ef 100644 --- a/data_gpu/driver/Makefile +++ b/data_gpu/driver/Makefile @@ -13,8 +13,15 @@ # contained in the LICENSE.txt file. # ---------------------------------------------------------------------------- +-include Makefile.local + # Args to this Makefile -NVIDIA_DRIVERS ?= "" +ifeq ($(NVIDIA_DRIVERS),) +$(error NVIDIA_DRIVERS is not set, please generate Makefile.local using build-nvidia.sh, or supply NVIDIA_DRIVERS on the command line) +endif + +$(info Using NVIDIA_DRIVERS=$(NVIDIA_DRIVERS)) + CC ?= "" # Define the module name. diff --git a/data_gpu/driver/build-nvidia.sh b/data_gpu/driver/build-nvidia.sh new file mode 100755 index 0000000..e76aa3d --- /dev/null +++ b/data_gpu/driver/build-nvidia.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +while test $# -gt 0; do + case $1 in + -v) + VERSION="$2" + shift 2; + ;; + -s) + SRCTREE="$2" + shift 2; + ;; + *) + echo "USAGE: $0 -s src_tree -v kver" + exit 1 + ;; + esac +done + +if [ $EUID -ne 0 ]; then + echo "This script must be run as root!" + exit 1 +fi + +if [ -z "$VERSION" ] || [ -z "$SRCTREE" ]; then + echo "USAGE: $0 -s src_tree -v kver" + exit 1 +fi + +# Determine the NVIDIA module version installed for this kernel +NVIDIA_VER=$(dkms status nvidia -k $VERSION | tr '/' '-' | awk -F, '{ print $1 }') + +# Generate a local Makefile that contains the configuration +echo "NVIDIA_DRIVERS=$SRCTREE/$NVIDIA_VER" > Makefile.local + +echo "--> Building NVIDIA drivers version $NVIDIA_VER" + +make -C "$SRCTREE/$NVIDIA_VER" -j$(nproc) + diff --git a/data_gpu/driver/dkms.conf b/data_gpu/driver/dkms.conf index 66ba094..d826393 100644 --- a/data_gpu/driver/dkms.conf +++ b/data_gpu/driver/dkms.conf @@ -1,9 +1,12 @@ -MAKE="make" +PRE_BUILD="./build-nvidia.sh -s $source_tree -v $kernelver" CLEAN="make clean" +MAKE="make" BUILT_MODULE_NAME=datagpu BUILT_MODULE_LOCATION=. -DEST_MODULE_LOCATION="/updates" +DEST_MODULE_LOCATION="/kernel/modules/misc" PACKAGE_NAME=datagpu-dkms REMAKE_INITRD=no AUTOINSTALL="yes" +BUILD_DEPENDS="nvidia" +NO_WEAK_MODULES="yes" #PACKAGE_VERSION=