Ubuntu 20.04 and driver 304.137 failed

I am running 20.04.1 on kubuntu x86_64, but having problems installing “NVIDIA GeForce 7300 GT” on 5.4.0-42-generic kernel at macPro1.1.

I tried with NVIDIA-Linux-x86_64-304.137.run .

nvidia-installer log file '/var/log/nvidia-installer.log’
creation time: Thu Aug 13 07:43:20 2020
installer version: 304.137

PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

nvidia-installer command line:

Using: nvidia-installer ncurses v6 user interface
-> License accepted.
-> Installing NVIDIA driver version 304.137.
-> There appears to already be a driver installed on your system (version: 304.137). As part of installing this driver (version: 304.137), the existing driver will be uninstalled. Are you sure you want to continue? (‘no’ will abort installation) (Answer: Yes)
-> Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later. (Answer: Yes)
-> Installing both new and classic TLS OpenGL libraries.
-> Installing classic TLS 32bit OpenGL libraries.
-> Install NVIDIA’s 32-bit compatibility OpenGL libraries? (Answer: No)
-> Uninstalling the previous installation with /usr/bin/nvidia-uninstall.
-> Searching for conflicting X files:
-> done.
-> Searching for conflicting OpenGL files:
-> done.
-> Installing ‘NVIDIA Accelerated Graphics Driver for Linux-x86_64’ (304.137):
executing: ‘/usr/sbin/ldconfig’…
executing: ‘/usr/sbin/depmod -aq’…
depmod: WARNING: Ignored deprecated option -q
-> done.
-> Driver file installation is complete.
-> Installing DKMS kernel module:
ERROR: Failed to run /usr/sbin/dkms build -m nvidia -v 304.137 -k 5.4.0-42-generic:
Kernel preparation unnecessary for this kernel. Skipping…

Building module:
cleaning build area…
make -j4 KERNELRELEASE=5.4.0-42-generic module SYSSRC=/lib/modules/5.4.0-42-generic/build…(bad exit status: 2)
ERROR (dkms apport): binary package for nvidia: 304.137 not found
Error! Bad return status for module build on kernel: 5.4.0-42-generic (x86_64)
Consult /var/lib/dkms/nvidia/304.137/build/make.log for more information.
-> error.
ERROR: Failed to install the kernel module through DKMS. No kernel module was installed; please try installing again without DKMS, or check the DKMS logs for more information.
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.

/var/lib/dkms/nvidia/304.137/build/make.log contains:

make -f ./scripts/Makefile.modbuiltin obj=arch/x86/platform
make -f ./scripts/Makefile.modbuiltin obj=arch/x86/platform/pvh
(for m in fs/configfs/configfs.ko; do echo $m; done;
cat /dev/null ) > fs/configfs/modules.builtin
make -f ./scripts/Makefile.modbuiltin obj=arch/x86/platform/atom
/usr/src/linux-headers-5.4.0-42-generic/tools/build/Makefile.build:37: /usr/src/linux-headers-5.4.0-42-generic/tools/build/Build.include: No such file or directory
make -f ./scripts/Makefile.modbuiltin obj=fs/crypto
make[6]: *** No rule to make target ‘/usr/src/linux-headers-5.4.0-42-generic/tools/build/Build.include’. Stop.
make[5]: *** [Makefile:43: /usr/src/linux-headers-5.4.0-42-generic/tools/objtool/fixdep-in.o] Error 2
make[4]: *** [/usr/src/linux-headers-5.4.0-42-generic/tools/build/Makefile.include:5: fixdep] Error 2

Any ideas?

yep got an idea. downgrade your kernel to linux 4.15…GENERIC and install headers accordingly. reboot and test before removing the kernel you had before. then follow the procedure to install patched nvidia 304.137…run driver you can find on the net.
you can easily downgrade with ukuu (package you can get as .deb file on the net) in (or without) combination with apt-get.
It worked for me. the DKMS module compiled and installed without the slightest error.
However I 'm stuck when launching nvidia-settings : 'you do not appear to be using the NV driver. Please edit x configuration file or simply launch nvidia-xconfig.
I launched nvidia-xconfig but it remains the same.