我下载并安装了一个使用 CUDA 10 的应用程序。当我运行它时,它显示:
./main: error while loading shared libraries: libcublas.so.10.0: cannot open shared object file: No such file or directory
文档说,它需要 CUDA 10 和 cuDNN。因此,我下载并安装了两者。(... 嗯,实际上我安装了 CUDA 10.1)。但这些都无济于事。我不确定要安装哪一个,所以我安装了开发版和运行时版。
但因为那仍然没有帮助,我安装了 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).
现在,我无法返回或返回。当我尝试卸载时,它会出现错误。
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).
此外,修复故障开关也无济于事。它尝试安装某些东西,然后再次出错。
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)
我怎样才能拯救我的系统?例如卸载所有内容。
答案1
我遇到了基本相同的问题,但接受的答案对我的情况(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
这两行应该会删除 9.1(它应该会从 中消失/usr/local
)。现在进行清理:
sudo apt autoremove
sudo apt update && sudo apt full-upgrade
答案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`
然后尝试删除违反 apt 的包。sudo dpkg -P cuda-libraries-10-0 libnvidia-common-390
下一步
sudo dpkg --configure -a && sudo apt -f install
某些软件包需要升级。但前提是您之前没有收到任何错误消息。
sudo apt update && sudo apt full-upgrade
答案3
无论是接受的答案也不是的答案user3658307
为我解决了这个问题(Ubuntu 18.04.5 LTS;与问题中的而不是/usr/include/cublas.h
相冲突)。相反,以下基于的解决方案libcublas-dev 10.2.2.89-1
10.2.0.168-1
这个答案对我有用:
sudo dpkg -i --force-overwrite /var/cache/apt/archives/nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb
执行此操作会导致出现很多dpkg: warning:
消息,甚至会出现以下输出:
[...]
dpkg: error processing package nvidia-cuda-dev (--install):
dependency problems - leaving unconfigured
[...]
但是,随后运行以下命令修复了我的机器上损坏的依赖关系:
sudo apt -f install