Failed Building Kernel Driver

uname -a

Linux trabajar2 5.15.0-2-amd64 #1 SMP Debian 5.15.5-1 (2021-11-26) x86_64 GNU/Linux

File I am suing : ./NVIDIA-Linux-x86_64-390.144.run

lspci

00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200/2nd Generation Core Processor Family PCI Express Root Port (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
00:16.0 Communication controller: Intel Corporation 6 Series/C200 Series Chipset Family MEI Controller #1 (rev 04)
00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (Lewisville) (rev 04)
00:1a.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 (rev b4)
00:1c.1 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 2 (rev b4)
00:1c.3 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 4 (rev b4)
00:1c.4 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 5 (rev b4)
00:1c.6 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 7 (rev b4)
00:1d.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation QM67 Express Chipset LPC Controller (rev 04)
00:1f.2 IDE interface: Intel Corporation 6 Series/C200 Series Chipset Family Mobile SATA Controller (IDE mode, ports 0-3) (rev 04)
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 04)
00:1f.5 IDE interface: Intel Corporation 6 Series/C200 Series Chipset Family Mobile SATA Controller (IDE mode, ports 4-5) (rev 04)
01:00.0 VGA compatible controller: NVIDIA Corporation GF108GLM [Quadro 1000M] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GF108 High Definition Audio Controller (rev a1)
03:00.0 Network controller: Qualcomm Atheros AR9485 Wireless Network Adapter (rev 01)
0d:00.0 System peripheral: Ricoh Co Ltd MMC/SD Host Controller (rev 08)
0d:00.3 FireWire (IEEE 1394): Ricoh Co Ltd R5C832 PCIe IEEE 1394 Controller (rev 04)
0e:00.0 USB controller: NEC Corporation uPD720200 USB 3.0 Host Controller (rev 04)

cat /var/log/nvidia-installer.log



| ^~~~~
| __state
make[3]: *** [/usr/src/linux-headers-5.15.0-2-common/scripts/Makefile.build:282: /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/os-interface.o] Error 1
make[3]: *** [/usr/src/linux-headers-5.15.0-2-common/scripts/Makefile.build:282: /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/nvlink_linux.o] Error 1
make[3]: Target ‘__build’ not remade because of errors.
make[2]: *** [/usr/src/linux-headers-5.15.0-2-common/Makefile:1892: /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel] Error 2
make[2]: Target ‘modules’ not remade because of errors.
make[2]: Leaving directory ‘/usr/src/linux-headers-5.15.0-2-amd64’
make[1]: *** [Makefile:231: __sub-make] Error 2
make[1]: Target ‘modules’ not remade because of errors.
make[1]: Leaving directory ‘/usr/src/linux-headers-5.15.0-2-common’
make: *** [Makefile:81: modules] Error 2
→ Error.
ERROR: An error occurred while performing the step: “Checking to see whether the nvidia kernel module was successfully built”. See /var/log/nvidia-installer.log for details.
→ The command cd ./kernel; /usr/bin/make -k -j8 NV_KERNEL_MODULES="nvidia" NV_EXCLUDE_KERNEL_MODULES="" SYSSRC="/lib/modules/5.15.0-2-amd64/source" SYSOUT="/lib/modules/5.15.0-2-amd64/build" failed with the following output:

make[1]: Entering directory ‘/usr/src/linux-headers-5.15.0-2-common’
make[2]: Entering directory ‘/usr/src/linux-headers-5.15.0-2-amd64’
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc-11 (Debian 11.2.0-12) 11.2.0
You are using: cc (Debian 11.2.0-12) 11.2.0
CC [M] /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/os-interface.o
CC [M] /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/nvlink_linux.o
In file included from /usr/src/linux-headers-5.15.0-2-common/include/linux/kernel.h:5,
from /usr/src/linux-headers-5.15.0-2-common/include/linux/list.h:9,
from /usr/src/linux-headers-5.15.0-2-common/include/linux/preempt.h:11,
from /usr/src/linux-headers-5.15.0-2-common/include/linux/spinlock.h:55,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/common/inc/nv-lock.h:16,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/common/inc/nv-linux.h:19,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/os-interface.c:15:
/usr/src/linux-headers-5.15.0-2-common/include/linux/stdarg.h:6: warning: “va_start” redefined
6 | #define va_start(v, l) __builtin_va_start(v, l)
|
In file included from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/common/inc/os-interface.h:27,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/os-interface.c:14:
/usr/lib/gcc/x86_64-linux-gnu/11/include/stdarg.h:47: note: this is the location of the previous definition
47 | #define va_start(v,l) __builtin_va_start(v,l)
|
In file included from /usr/src/linux-headers-5.15.0-2-common/include/linux/kernel.h:5,
from /usr/src/linux-headers-5.15.0-2-common/include/linux/list.h:9,
from /usr/src/linux-headers-5.15.0-2-common/include/linux/preempt.h:11,
from /usr/src/linux-headers-5.15.0-2-common/include/linux/spinlock.h:55,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/common/inc/nv-lock.h:16,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/common/inc/nv-linux.h:19,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/os-interface.c:15:
/usr/src/linux-headers-5.15.0-2-common/include/linux/stdarg.h:8: warning: “va_arg” redefined
8 | #define va_arg(v, T) __builtin_va_arg(v, T)
|
In file included from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/common/inc/os-interface.h:27,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/os-interface.c:14:
/usr/lib/gcc/x86_64-linux-gnu/11/include/stdarg.h:49: note: this is the location of the previous definition
49 | #define va_arg(v,l) __builtin_va_arg(v,l)
|
In file included from /usr/src/linux-headers-5.15.0-2-common/include/linux/kernel.h:5,
from /usr/src/linux-headers-5.15.0-2-common/include/linux/list.h:9,
from /usr/src/linux-headers-5.15.0-2-common/include/linux/preempt.h:11,
from /usr/src/linux-headers-5.15.0-2-common/include/linux/spinlock.h:55,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/common/inc/nv-lock.h:16,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/common/inc/nv-linux.h:19,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/os-interface.c:15:
/usr/src/linux-headers-5.15.0-2-common/include/linux/stdarg.h:9: warning: “va_copy” redefined
9 | #define va_copy(d, s) __builtin_va_copy(d, s)
|
In file included from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/common/inc/os-interface.h:27,
from /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/os-interface.c:14:
/usr/lib/gcc/x86_64-linux-gnu/11/include/stdarg.h:52: note: this is the location of the previous definition
52 | #define va_copy(d,s) __builtin_va_copy(d,s)
|
/tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/os-interface.c: In function ‘os_delay’:
/tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/os-interface.c:583:18: error: ‘struct task_struct’ has no member named ‘state’; did you mean ‘__state’?
583 | current->state = TASK_INTERRUPTIBLE;
| ^~~~~
| __state
/tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/nvlink_linux.c: In function ‘nvlink_sleep’:
/tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/nvlink_linux.c:600:18: error: ‘struct task_struct’ has no member named ‘state’; did you mean ‘__state’?
600 | current->state = TASK_INTERRUPTIBLE;
| ^~~~~
| __state
make[3]: *** [/usr/src/linux-headers-5.15.0-2-common/scripts/Makefile.build:282: /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/os-interface.o] Error 1
make[3]: *** [/usr/src/linux-headers-5.15.0-2-common/scripts/Makefile.build:282: /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel/nvidia/nvlink_linux.o] Error 1
make[3]: Target ‘__build’ not remade because of errors.
make[2]: *** [/usr/src/linux-headers-5.15.0-2-common/Makefile:1892: /tmp/selfgz1803/NVIDIA-Linux-x86_64-390.144/kernel] Error 2
make[2]: Target ‘modules’ not remade because of errors.
make[2]: Leaving directory ‘/usr/src/linux-headers-5.15.0-2-amd64’
make[1]: *** [Makefile:231: __sub-make] Error 2
make[1]: Target ‘modules’ not remade because of errors.
make[1]: Leaving directory ‘/usr/src/linux-headers-5.15.0-2-common’
make: *** [Makefile:81: modules] Error 2
ERROR: The nvidia kernel module was not created.
ERROR: Installation has failed. Please see the file ‘/var/log/nvidia-installer.log’ for details. You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.

] SOLVED SOLUTION [

I had to patch the Nvidia install file for my specific card. By using the following command.

./inttf-nvidia-patcher.sh -v 390.144

Go the script from here : inttf NVIDIA 340.xx, 418.xx, 435.xx, 515.xx Patcher for Kernel 6.0/5.19/5.18/5.17/5.16/5.15/5.14/5.13 [BASH Script] – If Not True Then False

It works for the latest kernels is the current Nvidia driver is slow to support the current kernel.

Run the following to see how to get it to support other cards.

./inttf-nvidia-patcher.sh -h

This script downloads the driver for you and path it.

I had to install libglvnd-dev to get things to work.

apt install libglvnd-dev

You will also want to download kernel drivers like this.

apt-get install linux-headers-uname -r build-essential