如何从 Ubuntu 18.04 中清除或完全删除 CUDA 并重新安装版本 10.2?

如何从 Ubuntu 18.04 中清除或完全删除 CUDA 并重新安装版本 10.2?

我似乎无法从系统中清除 NVidia 的 CUDA 软件包,尽管我已经执行sudo apt-get purge cudasudo apt autoremove

$ sudo apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  cuda-11-0 cuda-command-line-tools-11-0 cuda-compiler-11-0 cuda-cudart-11-0 cuda-cudart-dev-11-0 cuda-cuobjdump-11-0 cuda-cupti-11-0 cuda-cupti-dev-11-0
  cuda-demo-suite-11-0 cuda-documentation-11-0 cuda-driver-dev-11-0 cuda-drivers cuda-drivers-450 cuda-gdb-11-0 cuda-libraries-11-0
  cuda-libraries-dev-11-0 cuda-memcheck-11-0 cuda-nsight-11-0 cuda-nsight-compute-11-0 cuda-nsight-systems-11-0 cuda-nvcc-11-0 cuda-nvdisasm-11-0
  cuda-nvml-dev-11-0 cuda-nvprof-11-0 cuda-nvprune-11-0 cuda-nvrtc-11-0 cuda-nvrtc-dev-11-0 cuda-nvtx-11-0 cuda-nvvp-11-0 cuda-runtime-11-0
  cuda-samples-11-0 cuda-sanitizer-11-0 cuda-toolkit-11-0 cuda-tools-11-0 cuda-visual-tools-11-0 dkms libcublas-11-0 libcublas-dev-11-0 libcufft-11-0
  libcufft-dev-11-0 libcurand-11-0 libcurand-dev-11-0 libcusolver-11-0 libcusolver-dev-11-0 libcusparse-11-0 libcusparse-dev-11-0 libnpp-11-0
  libnpp-dev-11-0 libnvidia-cfg1-450 libnvidia-common-450 libnvidia-decode-450 libnvidia-encode-450 libnvidia-extra-450 libnvidia-fbc1-450
  libnvidia-gl-450 libnvidia-ifr1-450 libnvjpeg-11-0 libnvjpeg-dev-11-0 libxnvctrl0 nsight-compute-2020.1.2 nsight-systems-2020.3.2
  nvidia-compute-utils-450 nvidia-dkms-450 nvidia-driver-450 nvidia-kernel-common-450 nvidia-kernel-source-450 nvidia-modprobe nvidia-prime
  nvidia-settings nvidia-utils-450 screen-resolution-extra xserver-xorg-video-nvidia-450
0 upgraded, 0 newly installed, 72 to remove and 0 not upgraded.
After this operation, 5,042 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 282107 files and directories currently installed.)
Removing cuda-11-0 (11.0.3-1) ...
Removing cuda-toolkit-11-0 (11.0.3-1) ...
Removing cuda-tools-11-0 (11.0.3-1) ...
Removing cuda-command-line-tools-11-0 (11.0.3-1) ...
Removing cuda-compiler-11-0 (11.0.3-1) ...
Removing cuda-visual-tools-11-0 (11.0.3-1) ...
Removing cuda-documentation-11-0 (11.0.228-1) ...
Removing cuda-samples-11-0 (11.0.221-1) ...
Removing cuda-demo-suite-11-0 (11.0.167-1) ...
Removing cuda-runtime-11-0 (11.0.3-1) ...
Removing cuda-libraries-11-0 (11.0.3-1) ...
Removing cuda-gdb-11-0 (11.0.221-1) ...
Removing cuda-cuobjdump-11-0 (11.0.221-1) ...
Removing cuda-cupti-dev-11-0 (11.0.221-1) ...
Removing cuda-cupti-11-0 (11.0.221-1) ...
Removing cuda-libraries-dev-11-0 (11.0.3-1) ...
Removing cuda-drivers (450.51.06-1) ...
Removing cuda-drivers-450 (450.51.06-1) ...
Removing cuda-memcheck-11-0 (11.0.221-1) ...
Removing cuda-nsight-11-0 (11.0.221-1) ...
Removing cuda-nsight-compute-11-0 (11.0.3-1) ...
Removing cuda-nsight-systems-11-0 (11.0.3-1) ...
Removing cuda-nvcc-11-0 (11.0.221-1) ...
Removing cuda-nvdisasm-11-0 (11.0.221-1) ...
Removing cuda-nvml-dev-11-0 (11.0.167-1) ...
Removing cuda-nvprof-11-0 (11.0.221-1) ...
Removing cuda-nvprune-11-0 (11.0.221-1) ...
Removing cuda-nvrtc-dev-11-0 (11.0.221-1) ...
Removing cuda-nvrtc-11-0 (11.0.221-1) ...
Removing cuda-nvtx-11-0 (11.0.167-1) ...
Removing cuda-nvvp-11-0 (11.0.221-1) ...
Removing cuda-sanitizer-11-0 (11.0.221-1) ...
Removing nvidia-driver-450 (450.51.06-0ubuntu1) ...
Removing nvidia-dkms-450 (450.51.06-0ubuntu1) ...
Removing all DKMS Modules
Done.
INFO:Disable nvidia
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
update-initramfs: deferring update (trigger activated)
Removing dkms (2.3-3ubuntu9.7) ...
Removing libcublas-dev-11-0 (11.2.0.252-1) ...
Removing libcublas-11-0 (11.2.0.252-1) ...
Removing libcufft-dev-11-0 (10.2.1.245-1) ...
Removing libcufft-11-0 (10.2.1.245-1) ...
Removing libcurand-dev-11-0 (10.2.1.245-1) ...
Removing libcurand-11-0 (10.2.1.245-1) ...
Removing libcusolver-dev-11-0 (10.6.0.245-1) ...
Removing libcusolver-11-0 (10.6.0.245-1) ...
Removing libcusparse-dev-11-0 (11.1.1.245-1) ...
Removing libcusparse-11-0 (11.1.1.245-1) ...
Removing libnpp-dev-11-0 (11.1.0.245-1) ...
Removing libnpp-11-0 (11.1.0.245-1) ...
Removing xserver-xorg-video-nvidia-450 (450.51.06-0ubuntu1) ...
Removing libnvidia-cfg1-450:amd64 (450.51.06-0ubuntu1) ...
Removing libnvidia-ifr1-450:amd64 (450.51.06-0ubuntu1) ...
Removing libnvidia-gl-450:amd64 (450.51.06-0ubuntu1) ...
dpkg: warning: while removing libnvidia-gl-450:amd64, directory '/usr/share/vulkan/icd.d' not empty so not removed
Removing libnvidia-common-450 (450.51.06-0ubuntu1) ...
Removing libnvidia-encode-450:amd64 (450.51.06-0ubuntu1) ...
Removing libnvidia-decode-450:amd64 (450.51.06-0ubuntu1) ...
Removing libnvidia-extra-450:amd64 (450.51.06-0ubuntu1) ...
Removing libnvidia-fbc1-450:amd64 (450.51.06-0ubuntu1) ...
Removing libnvjpeg-dev-11-0 (11.1.1.245-1) ...
Removing libnvjpeg-11-0 (11.1.1.245-1) ...
Removing nvidia-settings (450.51.06-0ubuntu1) ...
Removing libxnvctrl0:amd64 (450.51.06-0ubuntu1) ...
Removing nsight-compute-2020.1.2 (2020.1.2.4-1) ...
Removing nsight-systems-2020.3.2 (2020.3.2.6-87e152c) ...
update-alternatives: removing manually selected alternative - switching nsys to auto mode
update-alternatives: removing manually selected alternative - switching nsight-sys to auto mode
update-alternatives: removing manually selected alternative - switching nsys-ui to auto mode
Removing nvidia-compute-utils-450 (450.51.06-0ubuntu1) ...
Removing nvidia-kernel-common-450 (450.51.06-0ubuntu1) ...
update-initramfs: deferring update (trigger activated)
Removing nvidia-kernel-source-450 (450.51.06-0ubuntu1) ...
Removing nvidia-modprobe (450.51.06-0ubuntu1) ...
Removing nvidia-prime (0.8.8.2) ...
Removing nvidia-utils-450 (450.51.06-0ubuntu1) ...
Removing screen-resolution-extra (0.17.3) ...
Removing cuda-cudart-dev-11-0 (11.0.221-1) ...
Removing cuda-cudart-11-0 (11.0.221-1) ...
Removing cuda-driver-dev-11-0 (11.0.221-1) ...
dpkg: warning: while removing cuda-driver-dev-11-0, directory '/usr/local' not empty so not removed
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for initramfs-tools (0.130ubuntu3.9) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-42-generic
I: The initramfs will attempt to resume from /dev/sda2
I: (UUID=xxxxx)
I: Set the RESUME variable to override this.
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for dbus (1.12.2-1ubuntu1.2) ...
Processing triggers for mime-support (3.60ubuntu1) ...

尽管如此,dpkg 表示它们存在。

$ dpkg -l | grep cuda
rc  cuda-cudart-10-2                                  10.2.89-1                                        amd64        CUDA Runtime native Libraries
rc  cuda-cudart-11-0                                  11.0.221-1                                       amd64        CUDA Runtime native Libraries
rc  cuda-cudart-dev-10-2                              10.2.89-1                                        amd64        CUDA Runtime native dev links, headers
rc  cuda-cufft-10-2                                   10.2.89-1                                        amd64        CUFFT native runtime libraries
rc  cuda-cupti-10-2                                   10.2.89-1                                        amd64        CUDA profiling tools runtime libs.
rc  cuda-curand-10-2                                  10.2.89-1                                        amd64        CURAND native runtime libraries
rc  cuda-cusolver-10-2                                10.2.89-1                                        amd64        CUDA solver native runtime libraries
rc  cuda-cusparse-10-2                                10.2.89-1                                        amd64        CUSPARSE native runtime libraries
rc  cuda-npp-10-2                                     10.2.89-1                                        amd64        NPP native runtime libraries
rc  cuda-nvcc-10-2                                    10.2.89-1                                        amd64        CUDA nvcc
rc  cuda-nvgraph-10-2                                 10.2.89-1                                        amd64        NVGRAPH native runtime libraries
rc  cuda-nvjpeg-10-2                                  10.2.89-1                                        amd64        NVJPEG native runtime libraries
rc  cuda-nvprof-10-2                                  10.2.89-1                                        amd64        CUDA Profiler tools
rc  cuda-nvrtc-10-2                                   10.2.89-1                                        amd64        NVRTC native runtime libraries
rc  cuda-nvtx-10-2                                    10.2.89-1                                        amd64        NVIDIA Tools Extension
ii  cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01 1.0-1                                            amd64        cuda repository configuration files
ii  cuda-repo-ubuntu1804-11-0-local                   11.0.3-450.51.06-1                               amd64        cuda repository configuration files
rc  cuda-sanitizer-api-10-2                           10.2.89-1                                        amd64        CUDA Sanitizer API
rc  cuda-toolkit-10-2                                 10.2.89-1                                        amd64        CUDA Toolkit 10.2 meta-package
rc  cuda-toolkit-11-0                                 11.0.3-1                                         amd64        CUDA Toolkit 11.0 meta-package
rc  cuda-visual-tools-10-2                            10.2.89-1                                        amd64        CUDA visual tools
rc  cuda-visual-tools-11-0                            11.0.3-1                                         amd64        CUDA visual tools

cuda再次尝试清除。虽然apt-get报告cuda未安装,但运行dpkg仍然报告cuda软件包已安装。

$ sudo apt-get autoremove --purge cuda
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'cuda' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

我的情况与此类似问题但那里的答案不起作用。

$ sudo apt-get purge libnccl-dev libnccl2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libnccl-dev
E: Unable to locate package libnccl2

更新:

我尝试cuda 10.2使用deb(本地)方法。但是,它失败了。我该如何克服这个问题?

$ sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
[sudo] password for xxxx: 
OK

$ sudo apt update
Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 https://download.virtualbox.org/virtualbox/debian bionic InRelease                                                        
Hit:3 https://typora.io/linux ./ InRelease                                                                                      
Hit:4 http://ppa.launchpad.net/dyatlov-igor/sierra-theme/ubuntu bionic InRelease                                                
Hit:5 http://archive.ubuntu.com/ubuntu bionic InRelease                                                                         
Hit:6 http://ppa.launchpad.net/git-core/ppa/ubuntu bionic InRelease                                                             
Get:7 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                                       
Hit:8 http://ppa.launchpad.net/micahflee/ppa/ubuntu bionic InRelease                                                            
Hit:9 https://deb.torproject.org/torproject.org bionic InRelease                                                                
Hit:10 http://archive.canonical.com/ubuntu bionic InRelease                                                                     
Hit:11 http://ppa.launchpad.net/openshot.developers/ppa/ubuntu bionic InRelease                                                 
Get:12 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]                                     
Get:13 http://archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                            
Get:14 https://mega.nz/linux/MEGAsync/xUbuntu_18.04 ./ InRelease [2,473 B]             
Fetched 254 kB in 2s (128 kB/s)                                   
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

$ sudo apt-get -y install cuda
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package cuda

$ apt-key list | grep cuda
Warning: apt-key output should not be parsed (stdout is not a terminal)
uid           [ unknown] cudatools <[email protected]>

答案1

我通过执行以下操作解决了我的问题:

  1. 使用sudo dpkg -r删除cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01 1.0-1cuda-repo-ubuntu1804-11-0-local
  2. 用于sudo dpkg -P单独清除所有 cuda deb 包。这些 deb 包按 列出dpkg -l | grep cuda。例如sudo dpkg -P cuda-cudart-10-2sudo dpkg -P cuda-cudart-11-0、...。

清除后,我重新做了安装命令命令sudo apt-get -y install cuda终于起作用了。还成功安装了补丁 1(2020 年 8 月 26 日发布)

$ dpkg -l | grep cuda
ii  cuda                                              10.2.89-1                                        amd64        CUDA meta-package
ii  cuda-10-2                                         10.2.89-1                                        amd64        CUDA 10.2 meta-package
ii  cuda-command-line-tools-10-2                      10.2.89-1                                        amd64        CUDA command-line tools
ii  cuda-compiler-10-2                                10.2.89-1                                        amd64        CUDA compiler
ii  cuda-cudart-10-2                                  10.2.89-1                                        amd64        CUDA Runtime native Libraries
ii  cuda-cudart-dev-10-2                              10.2.89-1                                        amd64        CUDA Runtime native dev links, headers
ii  cuda-cufft-10-2                                   10.2.89-1                                        amd64        CUFFT native runtime libraries
ii  cuda-cufft-dev-10-2                               10.2.89-1                                        amd64        CUFFT native dev links, headers
ii  cuda-cuobjdump-10-2                               10.2.89-1                                        amd64        CUDA cuobjdump
ii  cuda-cupti-10-2                                   10.2.89-1                                        amd64        CUDA profiling tools runtime libs.
ii  cuda-cupti-dev-10-2                               10.2.89-1                                        amd64        CUDA profiling tools interface.
ii  cuda-curand-10-2                                  10.2.89-1                                        amd64        CURAND native runtime libraries
ii  cuda-curand-dev-10-2                              10.2.89-1                                        amd64        CURAND native dev links, headers
ii  cuda-cusolver-10-2                                10.2.89-1                                        amd64        CUDA solver native runtime libraries
ii  cuda-cusolver-dev-10-2                            10.2.89-1                                        amd64        CUDA solver native dev links, headers
ii  cuda-cusparse-10-2                                10.2.89-1                                        amd64        CUSPARSE native runtime libraries
ii  cuda-cusparse-dev-10-2                            10.2.89-1                                        amd64        CUSPARSE native dev links, headers
ii  cuda-demo-suite-10-2                              10.2.89-1                                        amd64        Demo suite for CUDA
ii  cuda-documentation-10-2                           10.2.89-1                                        amd64        CUDA documentation
ii  cuda-driver-dev-10-2                              10.2.89-1                                        amd64        CUDA Driver native dev stub library
ii  cuda-drivers                                      440.33.01-1                                      amd64        CUDA Driver meta-package
ii  cuda-gdb-10-2                                     10.2.89-1                                        amd64        CUDA-GDB
ii  cuda-libraries-10-2                               10.2.89-1                                        amd64        CUDA Libraries 10.2 meta-package
ii  cuda-libraries-dev-10-2                           10.2.89-1                                        amd64        CUDA Libraries 10.2 development meta-package
ii  cuda-license-10-2                                 10.2.89-1                                        amd64        CUDA licenses
ii  cuda-memcheck-10-2                                10.2.89-1                                        amd64        CUDA-MEMCHECK
ii  cuda-misc-headers-10-2                            10.2.89-1                                        amd64        CUDA miscellaneous headers
ii  cuda-npp-10-2                                     10.2.89-1                                        amd64        NPP native runtime libraries
ii  cuda-npp-dev-10-2                                 10.2.89-1                                        amd64        NPP native dev links, headers
ii  cuda-nsight-10-2                                  10.2.89-1                                        amd64        CUDA nsight
ii  cuda-nsight-compute-10-2                          10.2.89-1                                        amd64        NVIDIA Nsight Compute
ii  cuda-nsight-systems-10-2                          10.2.89-1                                        amd64        NVIDIA Nsight Systems
ii  cuda-nvcc-10-2                                    10.2.89-1                                        amd64        CUDA nvcc
ii  cuda-nvdisasm-10-2                                10.2.89-1                                        amd64        CUDA disassembler
ii  cuda-nvgraph-10-2                                 10.2.89-1                                        amd64        NVGRAPH native runtime libraries
ii  cuda-nvgraph-dev-10-2                             10.2.89-1                                        amd64        NVGRAPH native dev links, headers
ii  cuda-nvjpeg-10-2                                  10.2.89-1                                        amd64        NVJPEG native runtime libraries
ii  cuda-nvjpeg-dev-10-2                              10.2.89-1                                        amd64        NVJPEG native dev links, headers
ii  cuda-nvml-dev-10-2                                10.2.89-1                                        amd64        NVML native dev links, headers
ii  cuda-nvprof-10-2                                  10.2.89-1                                        amd64        CUDA Profiler tools
ii  cuda-nvprune-10-2                                 10.2.89-1                                        amd64        CUDA nvprune
ii  cuda-nvrtc-10-2                                   10.2.89-1                                        amd64        NVRTC native runtime libraries
ii  cuda-nvrtc-dev-10-2                               10.2.89-1                                        amd64        NVRTC native dev links, headers
ii  cuda-nvtx-10-2                                    10.2.89-1                                        amd64        NVIDIA Tools Extension
ii  cuda-nvvp-10-2                                    10.2.89-1                                        amd64        CUDA nvvp
ii  cuda-repo-ubuntu1804-10-2-local                   10.2.1-1                                         amd64        cuda repository configuration files
ii  cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01 1.0-1                                            amd64        cuda repository configuration files
ii  cuda-runtime-10-2                                 10.2.89-1                                        amd64        CUDA Runtime 10.2 meta-package
ii  cuda-samples-10-2                                 10.2.89-1                                        amd64        CUDA example applications
ii  cuda-sanitizer-api-10-2                           10.2.89-1                                        amd64        CUDA Sanitizer API
ii  cuda-toolkit-10-2                                 10.2.89-1                                        amd64        CUDA Toolkit 10.2 meta-package
ii  cuda-tools-10-2                                   10.2.89-1                                        amd64        CUDA Tools meta-package
ii  cuda-visual-tools-10-2                            10.2.89-1                                        amd64        CUDA visual tools

相关内容