Installation of Nvidia driver 304.317 on Lubuntu 18.04 failed

I tried to install the Nvidia driver 304.317 according this post: Can't install Nvidia drivers on Ubuntu 18.04

During installation, several errors occurred:

Error message 1:

ERROR: Failed to run '/usr/sbin/dkms build -m nvidia -v 304.137 -k 5.0.0-23-generic': Kernel preparation unnecessary for this kernel. Skipping ... Building module: cleaning build area... make -j2 KERNELRELEASE=5.0.0-23-generic module SYSSRC=/lib/modules/5.0.0-23-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.0.0-23-generic (i686) Consult /var/lib/dkms/nvidia/304.137/build/make.log for more information. 

Error message 2:

ERROR: Failed to install the kernel module through DKMS. No kernel module was installed: please try to installing again without DKMS, or check the DKMS logs for more information. 

Error message 3:

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. 

nvidia-installer.log

nvidia-installer log file '/var/log/nvidia-installer.log' creation time: Sat Aug 10 21:13:58 2019 installer version: 304.137  PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin  nvidia-installer command line:     ./nvidia-installer  Unable to load: nvidia-installer ncurses v6 user interface  Using: nvidia-installer ncurses user interface -> License accepted. -> Installing NVIDIA driver version 304.137. -> Running distribution scripts    executing: '/usr/lib/nvidia/pre-install'... -> done. -> The distribution-provided pre-install script failed!  Continue installation anyway? (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. -> Searching for conflicting X files: -> done. -> Searching for conflicting OpenGL files: -> done. -> Installing 'NVIDIA Accelerated Graphics Driver for Linux-x86' (304.137):    executing: '/sbin/ldconfig'...    executing: '/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.0.0-23-generic`:  Kernel preparation unnecessary for this kernel.  Skipping...  Building module: cleaning build area... make -j2 KERNELRELEASE=5.0.0-23-generic module SYSSRC=/lib/modules/5.0.0-23-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.0.0-23-generic (i686) 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. 

make.log

DKMS make.log for nvidia-304.137 for kernel 5.0.0-23-generic (i686) Sa 10. Aug 21:14:49 CEST 2019 NVIDIA: calling KBUILD... Makefile:223: ================= WARNING ================ Makefile:224: 'SUBDIRS' will be removed after Linux 5.3 Makefile:225: Please use 'M=' or 'KBUILD_EXTMOD' instead Makefile:226: ========================================== test -e include/generated/autoconf.h -a -e include/config/auto.conf || (        \ echo >&2;                           \ echo >&2 "  ERROR: Kernel configuration is invalid.";       \ echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\ echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \ echo >&2 ;                          \ /bin/false) mkdir -p /var/lib/dkms/nvidia/304.137/build/.tmp_versions ; rm -f /var/lib/dkms/nvidia/304.137/build/.tmp_versions/* make -f ./scripts/Makefile.build obj=/var/lib/dkms/nvidia/304.137/build (cat /dev/null;   echo kernel//var/lib/dkms/nvidia/304.137/build/nvidia.ko;) > /var/lib/dkms/nvidia/304.137/build/modules.order [several compiler calls]   cc -Wp,-MD,/var/lib/dkms/nvidia/304.137/build/.os-interface.o.d  -nostdinc -isystem /usr/lib/gcc/i686-linux-gnu/7/include  -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include  -include ./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror-implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m32 -msoft-float -mregparm=3 -freg-struct-return -fno-pic -mpreferred-stack-boundary=2 -march=i686 -mtune=generic -Wa,-mtune=generic32 -ffreestanding -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -I/var/lib/dkms/nvidia/304.137/build -Wall -MD -Wsign-compare -Wno-cast-qual -Wno-error -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"304.137\" -Wno-unused-function -Wuninitialized -UDEBUG -U_DEBUG -DNDEBUG  -DMODULE  -DKBUILD_BASENAME='"os_interface"' -DKBUILD_MODNAME='"nvidia"' -c -o /var/lib/dkms/nvidia/304.137/build/os-interface.o /var/lib/dkms/nvidia/304.137/build/os-interface.c [several compiler warnings -Wsign-compare] /var/lib/dkms/nvidia/304.137/build/os-interface.c: In function ‘os_get_current_time’: /var/lib/dkms/nvidia/304.137/build/os-interface.c:667:5: error: implicit declaration of function ‘do_gettimeofday’; did you mean ‘efi_gettimeofday’? [-Werror=implicit-function-declaration]      do_gettimeofday(&tm);      ^~~~~~~~~~~~~~~      efi_gettimeofday [several compiler calls] Makefile:1606: recipe for target '_module_/var/lib/dkms/nvidia/304.137/build' failed make[2]: *** [_module_/var/lib/dkms/nvidia/304.137/build] Error 2 NVIDIA: left KBUILD. nvidia.ko failed to build! Makefile:262: recipe for target 'module' failed make[1]: *** [module] Error 1 makefile:59: recipe for target 'module' failed make: *** [module] Error 2 

I tried to install the driver without dkms, but I had the same problem. The readme from nvidia couldn’t help me out. Any suggestions?