Score:2

Can't install nvidia drivers on ubuntu 22.04

hr flag

I'm using a VM with Ubuntu 22.04 and trying to do GPU pass-through.

Nvidia graphic card is being detected on my VM

    Kernel driver in use: nvidia
    Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia

I did install the recommended nvidia drivers given by

ubuntu-drivers devices

Which is nvidia-drivers-390

However, when I run nvidia-smi it gives me

Failed to initialize NVML: Driver/library version mismatch

Further exploring the root cause I actually found

               NVRM: API mismatch: the client has version 530.30.02, but
               NVRM: this kernel module has version 390.157.  Please
               NVRM: make sure that this kernel module and all NVIDIA driver
               NVRM: components have the same version.

However, my graphic card only supports up to nvidia-drivers-470 since it's a GT 740M graphic card. How can I remove the client API 530 version since it is not on the list of drivers installed?

dpkg --get-selections | grep nvidia
libnvidia-cfg1-390:amd64            install
libnvidia-common-390                install
libnvidia-compute-390:amd64         install
libnvidia-compute-418-server:amd64      deinstall
libnvidia-decode-390:amd64          install
libnvidia-encode-390:amd64          install
libnvidia-fbc1-390:amd64            install
libnvidia-gl-390:amd64              install
libnvidia-ifr1-390:amd64            install
nvidia-compute-utils-390            install
nvidia-dkms-390                 install
nvidia-driver-390               install
nvidia-kernel-common-390            install
nvidia-kernel-source-390            install
nvidia-prime                    install
nvidia-settings                 install
nvidia-utils-390                install
xserver-xorg-video-nvidia-390           install

UPDATE:

I did find some folders using the following command

sudo find /usr/lib -iname "*nvidia*530*" 

I removed and then followed the answer of @Saxtheowl and now there are Nvidia-520 files. Some witch craft for sure :/

Saxtheowl avatar
iq flag
It might be a version mismatch
Score:2
iq flag

You can try to remove completely the existing Nvidia Drivers and reinstall a proper version

first purge the Nvidia drivers

sudo apt-get purge '^nvidia.*'
sudo rm -rf /etc/X11/xorg.conf
sudo rm -rf /etc/modprobe.d/nvidia*
sudo rm -rf /usr/local/nvidia*
sudo rm -rf /usr/lib/xorg/modules/drivers/nvidia*

then add the proper directories

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update

then install the good drivers sudo apt-get install nvidia-driver-470 then disable the nouveau drivers

sudo bash -c "echo 'blacklist nouveau' > /etc/modprobe.d/blacklist-nouveau.conf"
sudo bash -c "echo 'options nouveau modeset=0' >> /etc/modprobe.d/blacklist-nouveau.conf"

then update the initial ramdisk sudo update-initramfs -u

then reboot

if there is still error check sudo apt-get install nvidia-settings to be sure that all Component are upgraded correctly

Luis Pereira avatar
hr flag
Thanks for the detailed steps, however, it seems to not work, despite having a slightly different output ``` NVRM: API mismatch: the client has the version 520.61.05, but NVRM: this kernel module has the version 470.161.03. Please NVRM: make sure that this kernel module and all NVIDIA driver NVRM: components have the same version. ```
Saxtheowl avatar
iq flag
I am not sure if I have answered your question, you could try also by repeating the step and sudo apt-get install nvidia-driver to get sure to have the latest version
Luis Pereira avatar
hr flag
Problem is that my nvidia graphic card is a legacy one (GT 740M) which I can only use max 470 nvidia driver
Saxtheowl avatar
iq flag
I updated my answers, follow the step, I think I might not be able to help you if that does not fix your problem
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.