15

I have a dual-boot machine with Windows8 and Ubuntu 20.04.3 LTS.

It worked fine up until I pressed Yes (install) to some automatic updates from Ubuntu via the GUI pop-up window. These updates failed at around 70%. The problem is with nVidia drivers.

My motherboard is GT216 (GeForce GT 220). Running ubuntu-drivers devices I get:

driver: nvidia-340 - distro non-free recommended

driver: xserver-xorg-video-nouveau -distro free builtin.

After I shut down the computer after that failed update, at restart I got a login-infinite loop at the login screen (entered password, no login into Gnome Desktop, asked for password again, entered it again, no login into Gnome Desktop, repeat). I researched online and I found out that the nvidia-340 drivers are not compatible with my current kernel version.

Using tty terminals I worked through this tutorial https://www.if-not-true-then-false.com/2020/inttf-nvidia-patcher/ and then I installed nvidia-340 by running the executable I got via the tutorial. I followed the steps from here: https://www.if-not-true-then-false.com/2021/debian-ubuntu-linux-mint-nvidia-guide/#before-installation. I can now login into Gnome.

Problem:

All my graphics programs are destroyed. In the past when my machine was functioning properly, I had installed Qt5 and linked against a framework I use for work. Now that framework doesn't function anymore, I cannot compile programs against the visualization drivers anymore.

I tried to reinstall the visualization drivers again, as I did 3-4 months ago on the same machine (when I successfully set up that framework I use for work): but I fail at the very first step: sudo apt install qt5-default

Removing nvidia-340 (340.108-0ubuntu5.20.04.2)... /var/lib/dpkg/info/nvidia-340.postrm: 59: /usr/sbin/update-initramfs: not found

dpkg: error processing package nvidia-340 (--remove):

installed nvidia-340 package post-removal script subprocess returned error exit status 127

dpkg: too many errors, stopping

Errors were encountered while processing:

nvidia-340

Processing was halted because there were too many errorrs.

E: Sub-process /usr/bin/dpkg reurned an error code (1).

Attemtps I did:

  1. I have tried to do what it's written in here Ubuntu 18.10 problem with Nvidia 340 drivers

  2. I have tried to run sudo apt-get install nvidia-current : E : Package 'nvidia-current' has no installation candidate

  3. I have tried to switch to Nouveau from the Applications -> Software & Updates -> Additional Drivers, but it doesn't work. When I click to switch to that, Error while applying changes: pk-client-error-quark: Error while installing package: installed nvidia-340 package post-removal script subprocess returned error exit status 127 (313)

  4. I have tried to run nvidia-settings -> this pops up a new window with various information, which I can provide if needed.

  5. I have tried to run sudo apt-ache policy nvidia-340 -> this returns nvidia -340 : Installed : 340-108-0ubuntu5.20.04.2 candidate : 340-108-0ubuntu5.20.04.2 ... etc

  6. I have tried to run which nvidia-smi -> this returns nothing

6') I have tried to run nvidia-smi -> returns 'nvidia-smi' command nout found, can be installed with: and here appears a list of nvidia drivers it recommends installing via sudo apt install nvidia-XYZ or sudo apt install nvidia-utils-XYZ.

  1. I have tried to run sudo ubuntu-drivers autoinstall -> this returns the same thing as before: The following packages will be removed: nvidia-340 Removing nvidia-340 ... dpkg: error processing package nvidia-340 (--remove): installed nvidia-340 package post-removal script subprocess returned error exit status 127 dpkg: too many errors, stopping Errors were encountered while processing: nvidia-340 ...

  2. I have tried to run sudo apt-get install nvidia-340 -> this returns that nvidida-340 is already the newest version (340.108-0ubuntu5.20.04.2) 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 1 not fully installed or removed. Need to get 52,0 MB of archives. After this operation, 0B of additional disk space will be used. Do you want to continue ? Yes Y Get: 1 ... Fetched 52,0 MB in 2 s Processing triggers for libc-bin (2.31-0ubuntu9.2) ... and here I don't get any more returned statements and I just get a new line on the terminal to enter a new command as in $ > ... (so process exits alright and I can just continue doing stuff).

When writing (to configure my framework again) sudo apt install qt5-default I again get the same errors as above (in the Problem section)

Do you know what is happening or what shall I do? I really want to be able to compile applications again and run them on my machine.

I can provide any necessary info which might be useful to solve my problem.

Thank you in advance!

Edit (new info):

My current kernel version which appears as output when running uname -r is:

5.11.0-36-generic

velenos14
  • 263

2 Answers2

16

You'll need to install the 5.4 kernel, and uninstall 5.11.

  1. sudo apt purge nvidia*

  2. sudo apt install --install-recommends linux-generic

  3. Now reboot, and select kernel 5.4 at grub menu.

  4. sudo apt remove --purge linux-generic-hwe-20.04 linux-hwe-* linux-modules-5.11* linux-modules-extra-5.11*

  5. If everything worked so far, run sudo ubuntu-drivers autoinstall to install Nvidia driver.

mikewhatever
  • 33,013
15

Sticking with 5.4 kernel will not be an option forever. I had the same issue with a early 2009 iMac, where the last proprietary nvidia driver available for my C79 [GeForce 9400] card is also nvidia-340.

As said by others, this driver is not supported by kernels > 5.4.

It means the day you will go for a newer kernel (you will have to, soon or later), you will have 2 choices :

  1. try nouveau driver (I had lots of freeze issues on my iMac, but it could work for you, our cards are different)
  2. keep the nvidia-340 proprietary driver with the more recent kernel

For (2), there is a solution.

Basically, boot on your new kernel (like 5.11, with for instance nouveau driver), and do what is explained in the link above, something like :

sudo add-apt-repository ppa:kelebek333/nvidia-legacy
sudo apt-get update
sudo apt install nvidia-340

Warning: below line for kernels >= 5.11

sudo apt install xorg-modulepath-fix

I did upgrade from 20.04 (kernel 5.4, already with kelebek333's nvidia-340 version) to 21.10 (kernel 5.13) on the old iMac (I had no issue during the upgrade itself). The upgrade process did remove kelebeck333 repo), and enabled the nouveau driver.

After booting the new system, I did apply (again) the commands above, and my nvidia configuration is now :

$ lsb_release  -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 21.10
Release:    21.10
Codename:   impish

$ uname -r 5.13.0-28-generic

$ dpkg -l | grep nvidia ii nvidia-340 340.108-4lmtrimpish3 amd64 NVIDIA binary driver - version 340.108 ii nvidia-opencl-icd-340 340.108-4lmtrimpish3 amd64 NVIDIA OpenCL ICD ii nvidia-settings 470.57.01-0ubuntu3 amd64 Tool for configuring the NVIDIA graphics driver ii screen-resolution-extra 0.18.1 all Extension for the nvidia-settings control panel

$ inxi -Gx Graphics: Device-1: NVIDIA C79 [GeForce 9400] vendor: Apple iMac 9 1 driver: nvidia v: 340.108 bus-ID: 03:00.0 Device-2: Apple Built-in iSight type: USB driver: uvcvideo bus-ID: 1-4:2 Display: server: X.org 1.20.13 driver: loaded: nvidia tty: 186x32

EDIT: The above upgrade procedure also applies to Ubuntu 22.04 (kernel 5.15).

braoult
  • 292