无法安装或卸载 CUDA,并且 dkpg 无法安装任何东西

无法安装或卸载 CUDA,并且 dkpg 无法安装任何东西

当我执行 sudo apt --fix-broken install

    Errors were encountered while processing:
 /tmp/apt-dpkg-install-6CZ1pM/00-cuda-cudart-11-0_11.0.221-1_amd64.deb
 /tmp/apt-dpkg-install-6CZ1pM/01-cuda-driver-dev-11-0_11.0.221-1_amd64.deb
 /tmp/apt-dpkg-install-6CZ1pM/02-cuda-cudart-dev-11-0_11.0.221-1_amd64.deb
 /tmp/apt-dpkg-install-6CZ1pM/03-cuda-nvcc-11-0_11.0.221-1_amd64.deb
 /tmp/apt-dpkg-install-6CZ1pM/04-cuda-cupti-11-0_11.0.221-1_amd64.deb
 /tmp/apt-dpkg-install-6CZ1pM/05-cuda-cupti-dev-11-0_11.0.221-1_amd64.deb
 /tmp/apt-dpkg-install-6CZ1pM/06-cuda-nvprof-11-0_11.0.221-1_amd64.deb
 /tmp/apt-dpkg-install-6CZ1pM/07-cuda-nvtx-11-0_11.0.167-1_amd64.deb
 /tmp/apt-dpkg-install-6CZ1pM/08-cuda-nvrtc-11-0_11.0.221-1_amd64.deb
 /tmp/apt-dpkg-install-6CZ1pM/09-cuda-nvrtc-dev-11-0_11.0.221-1_amd64.deb
 /tmp/apt-dpkg-install-6CZ1pM/10-libcublas-11-0_11.2.0.252-1_amd64.deb
 /tmp/apt-dpkg-install-6CZ1pM/11-libcublas-dev-11-0_11.2.0.252-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

当我执行 sudo apt install aptitude

The following packages have unmet dependencies:
 aptitude : Depends: aptitude-common (= 0.8.12-1ubuntu4) but it is not going to be installed
            Depends: libcwidget4 (>= 0.5.18-1) but it is not going to be installed
            Depends: libxapian30 (>= 1.4.14~) but it is not going to be installed
            Recommends: libparse-debianchangelog-perl but it is not going to be installed
 cuda-command-line-tools-11-0 : Depends: cuda-cupti-dev-11-0 (>= 11.0.221) but it is not going to be installed
                                Depends: cuda-nvprof-11-0 (>= 11.0.221) but it is not going to be installed
                                Depends: cuda-nvtx-11-0 (>= 11.0.167) but it is not going to be installed
 cuda-compiler-11-0 : Depends: cuda-nvcc-11-0 (>= 11.0.221) but it is not going to be installed
 cuda-libraries-11-0 : Depends: cuda-cudart-11-0 (>= 11.0.221) but it is not going to be installed
                       Depends: cuda-nvrtc-11-0 (>= 11.0.221) but it is not going to be installed
                       Depends: libcublas-11-0 (>= 11.2.0.252) but it is not going to be installed
 cuda-libraries-dev-11-0 : Depends: cuda-cudart-dev-11-0 (>= 11.0.221) but it is not going to be installed
                           Depends: cuda-driver-dev-11-0 (>= 11.0.221) but it is not going to be installed
                           Depends: cuda-nvrtc-dev-11-0 (>= 11.0.221) but it is not going to be installed
                           Depends: libcublas-dev-11-0 (>= 11.2.0.252) but it is not going to be installed
 cuda-samples-11-0 : Depends: cuda-nvrtc-dev-11-0 but it is not going to be installed
                     Depends: cuda-nvcc-11-0 but it is not going to be installed
                     Depends: libcublas-dev-11-0 but it is not going to be installed
                     Depends: cuda-cudart-dev-11-0 but it is not going to be installed
                     Depends: cuda-driver-dev-11-0 but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

任何帮助都将不胜感激,我是新手

也尝试过

sudo apt-get clean
sudo apt-get -f install

在 /usr/local 中找不到 cuda 文件,但是 nvidia-smi 说 CUDA 版本为 11.4

答案1

我认为我已经找到了解决方案,现在它似乎正在发挥作用

升级或卸载 cuda 以允许 apt-get 工作

dpkg -l | grep cuda- | awk '{print $2}' | xargs -n1 sudo dpkg --purge
df -h
sudo apt-get purge nvidia*
sudo apt-get -f install
sudo apt autoremove

答案2

一个未经测试但类似的答案可能会更好......

sudo apt-get install $(dpkg -l | awk '/cuda-|nvidia-/ {print $2 "-"}' ) cuda

基本上,这允许删除所有 cuda 和 nvidia 软件包,然后一步安装 cuda。这允许 apt-get 保留不冲突的所有内容并删除冲突的内容。

相关内容