Score:3

CUDA uninstallation, removing package not possible

es flag

On my dev system (Kubuntu 20.04) I just installed CUDA 11.3. After checking the installation, I found some older CUDA packages installed, which are remainders from experiments some time ago. That CUDA 11.2 installation was incomplete, so I needed to remove the packages one-by-one (not via the "cuda" metapackage). I was able remove all of them except one: cuda-cudart-11-2.

When running sudo apt remove cuda-cudart-11-2 or sudo apt --purge remove cuda-cudart-11-2, apt names two new packages that need to be installed before removing cuda-cudart-11-2:

  • cuda-toolkit-11-config-common
  • cuda-toolkit-config-common

My first question: How can removing a package require installing new packages? I have never seen this before.

I confirmed the installation of those packages as proposed by apt and got errors:

me@mypc:~$ sudo apt remove cuda-cudart-11-2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  cuda-toolkit-11-config-common cuda-toolkit-config-common
The following packages will be REMOVED:
  cuda-cudart-11-2
The following NEW packages will be installed:
  cuda-toolkit-11-config-common cuda-toolkit-config-common
0 upgraded, 2 newly installed, 1 to remove and 0 not upgraded.
Need to get 0 B/32.2 kB of archives.
After this operation, 514 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 380817 files and directories currently installed.)
Preparing to unpack .../cuda-toolkit-11-config-common_11.3.109-1_all.deb ...
Unpacking cuda-toolkit-11-config-common (11.3.109-1) ...
dpkg: error processing archive /var/cache/apt/archives/cuda-toolkit-11-config-common_11.3.109-1_all.deb (--unpack):
 trying to overwrite '/etc/ld.so.conf.d/989_cuda-11.conf', which is also in package cuda-cudart-11-2 11.2.152-1
Preparing to unpack .../cuda-toolkit-config-common_11.3.109-1_all.deb ...
Unpacking cuda-toolkit-config-common (11.3.109-1) ...
dpkg: error processing archive /var/cache/apt/archives/cuda-toolkit-config-common_11.3.109-1_all.deb (--unpack):
 trying to overwrite '/etc/ld.so.conf.d/000_cuda.conf', which is also in package cuda-cudart-11-2 11.2.152-1
Errors were encountered while processing:
 /var/cache/apt/archives/cuda-toolkit-11-config-common_11.3.109-1_all.deb
 /var/cache/apt/archives/cuda-toolkit-config-common_11.3.109-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

As far as I understand, this says that cuda-toolkit-11-config-common can not be installed because the config file /etc/ld.so.conf.d/989_cuda-11.conf can not be overwritten because it is in use by cuda-cudart-11-2 (which can not be removed until cuda-toolkit-11-config-common is installed). This sounds like a kind of deadlock to me.

My seconds question: If this is actually a deadlock, how can I solve it?

Jerare avatar
in flag
Just do the process and try to remove cuda-toolkit-11-config-common after. Maybe it will resolve the dependency problem and you'll be able to remove CUDA. If it doesn't work then you are in a deadlock :/
es flag
@Jerare I can't install cuda-toolkit-11-config-common because it wants to overwrite a configuration file that is in use. Is my English unclear on this?
user.dz avatar
ng flag
Could you try the solution in https://askubuntu.com/q/56761/26246 .About you question, it is possible that apt was already having a stuck packages, and they will show up whenever you launch apt. Also if you have used aptitude or synaptic, if there are packages that are manually installed and depend on that package. aptitude and synaptic may look for alternatives to not break dependencies.
es flag
@user.dz Never used aptitude or synaptic. If those are stuck packages, apt should offer them anytime, even when installing something totally unrelated? I tried to install some random application package and apt did not mention the cuda-toolkit*-config-common packages.
es flag
@user.dz The linked solution kind of worked. I was able to force-install the proposed packages and could remove the old package immediately after. The config files have not been update but I guess they are still valid.
es flag
Still my first question is not answered
user.dz avatar
ng flag
@Silicomancer they are dependencies of cuda as per https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/Packages , it just happen the installation hadn't complete in first place. When 1st time did you notice that APT has issue, have you ever run apt for another reason like update after installing cuda?
es flag
@user.dz I'm pretty sure I didn't do anyhing else after installing cuda package. I installed it, then noticed the version I got was newer than expected (11.3 instead of 11.2), then I listed all packages containing "cuda", found old 11.2 packages and removed them (well, most of them). I didn't notice an error during cuda installation. Is there some log in linux that contains package installation runs?
user.dz avatar
ng flag
Yes, `/var/log/dpkg.log*`
es flag
Had a look in the log. I don't get it. I don't see anything that looks like a failure, even for the failed removales nor for the failed installs.
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.