Score:0

Unable to install Nvidia drivers

sn flag

I am unable to install the Nvidia driver on my Ubuntu 22.04. Previously, I had working Nvidia drivers and CUDA installation. However, to install python libraries such as pyTorch etc. I had to uninstall and install CUDA several times. Meanwhile I also had to downgrade my gcc from 11.3 to 9 as some of these libraries are not compatible with higher versions. The problem is now that when I am trying to install Nvidia driver (latest or recommended) there is some problem with the kernel. It says that my kernel was compiled using gcc version 11.3, but you are trying to build using gcc 9.5.

make.log:

$cat /var/lib/dkms/nvidia/470.182.03/build/make.log
DKMS make.log for nvidia-470.182.03 for kernel 5.15.0-69-generic (x86_64)
Do 27. Apr 12:11:09 IST 2023
make[1]: Entering directory '/usr/src/linux-headers-5.15.0-69-generic'
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)
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
  You are using:           gcc (Ubuntu 9.5.0-1ubuntu1~22.04) 9.5.0
make -f ./scripts/Makefile.build obj=/var/lib/dkms/nvidia/470.182.03/build \
single-build= \
need-builtin=1 need-modorder=1
  ln -sf /var/lib/dkms/nvidia/470.182.03/build/nvidia/nv-kernel.o_binary /var/lib/dkms/nvidia/470.182.03/build/nvidia/nv-kernel.o
  ln -sf /var/lib/dkms/nvidia/470.182.03/build/nvidia-modeset/nv-modeset-kernel.o_binary /var/lib/dkms/nvidia/470.182.03/build/nvidia-modeset/nv-modeset-kernel.o
 CONFTEST: hash__remap_4k_pfn
.
.
.
gcc: error: unrecognized command line option ‘-mharden-sls=all’
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/nvidia/470.182.03/build/nvidia/nv.o] Error 1
make[2]: *** Waiting for unfinished jobs....
gcc: error: unrecognized command line option ‘-mharden-sls=all’
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/nvidia/470.182.03/build/nvidia/nv-pci.o] Error 1
gcc: error: unrecognized command line option ‘-mharden-sls=all’
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/nvidia/470.182.03/build/nvidia/nv-acpi.o] Error 1
make[1]: *** [Makefile:1906: /var/lib/dkms/nvidia/470.182.03/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.0-69-generic'
make: *** [Makefile:80: modules] Error 2

When I try to upgrade gcc with sudo apt install gcc I get the following error:

ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/nvidia-kernel-s
ource-470.0.crash'
Error! Bad return status for module build on kernel: 5.15.0-69-generic (x86_64)
Consult /var/lib/dkms/nvidia/470.182.03/build/make.log for more information.
dpkg: error processing package nvidia-dkms-470 (--configure):
 installed nvidia-dkms-470 package post-installation script subprocess returned 
error exit status 10
dpkg: dependency problems prevent configuration of nvidia-driver-470:
 nvidia-driver-470 depends on nvidia-dkms-470 (<= 470.182.03-1); however:
  Package nvidia-dkms-470 is not configured yet.
 nvidia-driver-470 depends on nvidia-dkms-470 (>= 470.182.03); however:
  Package nvidia-dkms-470 is not configured yet.

dpkg: error processing package nvidia-driver-470 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup erro
r from a previous failure.
                          Processing triggers for initramfs-tools (0.140ubuntu13
.1) ...
update-initramfs: Generating /boot/initrd.img-5.15.0-71-generic
Errors were encountered while processing:
 nvidia-dkms-470
 nvidia-driver-470
E: Sub-process /usr/bin/dpkg returned an error code (1)
David avatar
cn flag
You downgraded a needed version of a module. Never a good idea. A better idea would have been a container and a version of Ubuntu that does use this lower version module. Try and restore the version you down graded from.
Nmath avatar
ng flag
This sounds like "dependency hell". It can be hard to recover from forcing versions of software that aren't supported by your release. In particular, messing around with your python versions and libraries can break a lot of different things. Often in these cases it's more prudent to reinstall the entire OS than try to sort out all of the collateral damage. This may be a "live and learn" experience. If you still need help with this, we need to be able to parse your details, which is not possible how you've presented it. Please fix your formatting: https://meta.askubuntu.com/a/20164
Jitesh Jhawar avatar
sn flag
Yeah, reinstalling seems the best for now. Thanks for your reply.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.