卸载损坏的 cuda 安装

bvd*_*vdb 5 package-management apt cuda

我下载并安装了一个使用 CUDA 10 的应用程序。当我运行它时,它说:

./main: error while loading shared libraries: libcublas.so.10.0: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)

文档说,它需要 CUDA 10 和 cuDNN。所以,我下载并安装了两者。(...好吧,实际上我安装了 CUDA 10.1)。但这些都没有帮助。我不确定要安装哪一个,所以我安装了 dev 和 runtime。

因为仍然没有帮助,我安装了 nvidia-cuda-toolkit。我认为那是事情真正出错的时候。不可避免的事情发生了,我打破了它。

我想再安装一个包:即“cuda-libraries”,但它给出了一个未满足的依赖错误,参考我之前安装的 nvidia 工具包。

user@dxxx:~/x$ sudo apt install cuda-libraries-10-0
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 cuda-libraries-10-0 : Depends: cuda-nvrtc-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-nvgraph-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-nvjpeg-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-cusolver-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-cublas-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-cufft-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-curand-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-cusparse-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-npp-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-cudart-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-license-10-0 (>= 10.0.130) but it is not going to be installed
 nvidia-cuda-toolkit : Depends: nvidia-cuda-dev (= 9.1.85-3ubuntu1) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
Run Code Online (Sandbox Code Playgroud)

现在,我不能来回走动。当我尝试卸载它时会出现错误。

user@xxx:~/x$ sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 nvidia-cuda-toolkit : Depends: nvidia-cuda-dev (= 9.1.85-3ubuntu1) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
Run Code Online (Sandbox Code Playgroud)

此外,损坏修复开关也无济于事。它尝试安装某些东西,然后再次出错。

user@xxx:~/x$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following package was automatically installed and is no longer required:
  libnvidia-common-390
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  nvidia-cuda-dev
Recommended packages:
  libnvcuvid1
The following NEW packages will be installed:
  nvidia-cuda-dev
0 upgraded, 1 newly installed, 0 to remove and 142 not upgraded.
54 not fully installed or removed.
Need to get 0 B/263 MB of archives.
After this operation, 734 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 205855 files and directories currently installed.)
Preparing to unpack .../nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb ...
Unpacking nvidia-cuda-dev (9.1.85-3ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb (--unpack):
 trying to overwrite '/usr/include/cublas.h', which is also in package libcublas-dev 10.2.0.168-1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

如何保存我的系统?例如卸载所有的。

小智 6

我遇到了基本相同的问题,但接受的答案在我的情况下不起作用(Ubuntu 18.04)。我已经安装了cuda-10.1,但是(如原始问题中所示)cuda-9.1仍然存在。这篇文章很有帮助。

dpkg -l | grep -e cuda-.*9-1 | awk '{print $2}' | xargs -n1 sudo dpkg --purge --force-all
sudo apt-get remove nvidia-cuda-toolkit
Run Code Online (Sandbox Code Playgroud)

这两行应该删除 9.1(它应该从 中消失/usr/local)。现在清理:

sudo apt autoremove
sudo apt update && sudo apt full-upgrade
Run Code Online (Sandbox Code Playgroud)


nob*_*ody 2

为了一个新的开始。 sudo mv /usr/include/cublas.h /usr/include/cublas.h.bak

dpkg:处理存档/var/cache/apt/archives/nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb(--unpack)时出错:尝试覆盖'/usr/include/cublas.h',它也在包中libcublas-dev 10.2.0.168-1

2 个软件包包含相同的文件,并且 dpkg 在没有任何 --force 选项的情况下不会覆盖它。

sudo dpkg --configure nvidia-cuda-dev and ` sudo dpkg --configure nvidia-cuda-toolkit`
Run Code Online (Sandbox Code Playgroud)

然后尝试删除违反apt的包。sudo dpkg -P cuda-libraries-10-0 libnvidia-common-390

下一步

sudo dpkg --configure -a && sudo apt -f install
Run Code Online (Sandbox Code Playgroud)

一些软件包需要升级。但前提是您之前没有收到错误消息。

sudo apt update && sudo apt full-upgrade
Run Code Online (Sandbox Code Playgroud)