Score:3

Accidentally rejected nvidia-cudnn license install with apt, now I can't uninstall it

vc flag

I tried installing nvidia-cudnn and was being a bit fast and lose with the prompts. I accidentally hit reject when trying to install it. Now when I try to uninstall I get the following error:

$ sudo apt purge nvidia-cudnn -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED
  nvidia-cudnn*
0 to upgrade, 0 to newly install, 1 to remove and 3 not to upgrade.
After this operation, 45.1 kB disk space will be freed.
(Reading database ... 203730 files and directories currently installed.)
Removing nvidia-cudnn (8.2.4.15~cuda11.4) ...
Purging cuDNN installation from /usr
dpkg: error processing package nvidia-cudnn (--remove):
 installed nvidia-cudnn package pre-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 nvidia-cudnn
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

Manually removing sudo rm -r /usr/share/doc/nvidia-cudnn and sudo rm /var/lib/dpkg/info/nvidia-cudnn* then sudo apt purge nvidia-cudnn doesn't seem to do the trick. When I try and install it again, i'm not prompted for the license anymore. I've tried rebooting in between "uninstalling" and reinstalling. Where is the license accepted/rejected information kept? How can I force it to prompt me with the license again?

Both before and after the messup I used this command to install cudnn sudo apt install nvidia-cudnn

Now all I get is:

$ sudo apt install nvidia-cudnn 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed
  nvidia-cudnn
0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.
Need to get 13.2 kB of archives.
After this operation, 45.1 kB of additional disk space will be used.
Get:1 http://gb.archive.ubuntu.com/ubuntu jammy/multiverse amd64 nvidia-cudnn amd64 8.2.4.15~cuda11.4 [13.2 kB]
Fetched 13.2 kB in 0s (971 kB/s)        
Preconfiguring packages ...
Selecting previously unselected package nvidia-cudnn.
(Reading database ... 203718 files and directories currently installed.)
Preparing to unpack .../nvidia-cudnn_8.2.4.15~cuda11.4_amd64.deb ...
Unpacking nvidia-cudnn (8.2.4.15~cuda11.4) ...
Setting up nvidia-cudnn (8.2.4.15~cuda11.4) ...
David avatar
cn flag
Please edit the question and add the exact command you used to install it . Yes it matters.
McAngus avatar
vc flag
Sorry! @David I've added the command.
David avatar
cn flag
Is it installed correctly now?
user10489 avatar
in flag
If you know which package is misinstalled, you could try dpkg-reconfigure to fix it
McAngus avatar
vc flag
@David It's not. I still get errors trying to uninstall it. dpkg-reconfigure didn't seem to help. It just output `Purging cuDNN installation from /usr` and then `sudo apt remove nvidia-cudnn` gave the same error as before.
Score:4
aq flag

The uninstall process fails as the pre-removal script (/var/lib/dpkg/info/nvidia-cudnn.prerm) returns non-zero exit status. Inside, the pre-removal script calls update-nvidia-cudnn -p located in /usr/sbin/update-nvidia-cudnn which after line 164 (echo Purging cuDNN installation from ${PREFIX}) runs a command purge_cudnn ${PREFIX} that fails.

I was able to fix the issue by forcing exit 0 from update-nvidia-cudnn -p, by adding exit 0 after line 164 in file /usr/sbin/update-nvidia-cudnn.

To sum up, edit the end of file /usr/sbin/update-nvidia-cudnn to:

...
elif test "${DO_PURGE}" -ne 0; then
    echo Purging cuDNN installation from ${PREFIX}
    exit 0  # added
    purge_cudnn ${PREFIX}
fi

and the uninstall process becomes possible. Then if nvidia-cudnn is installed again, the installer will ask you again to agree to the license.

Brian D avatar
ng flag
the `purge_cudnn` function in that file essentially runs `rm -rv ...` on a bunch of files, so by exiting before that you're skipping their removal and essentially doing nothing at all?
Score:1
cn flag

To remove an app you have installed the correct way to do so is the reverse command of the install.

sudo apt install nvidia-cudnn

This is the command you used to do the install. Therefore the command to remove the app would be.

sudo apt remove nvidia-cudnn

A force remove is a bad idea and may leave bits behind.

McAngus avatar
vc flag
remove gives me the same error as purge (see my question for full output) `Errors were encountered while processing: nvidia-cudnn`
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.