注意:是否安装了 NVIDIA 显卡驱动,nvidia-smi
命令第一行如果显示驱动版本说明已经安装了 由于我使用的是 docker
虚拟化出来 Ubuntu20.04
且主机已经给安装了驱动,因此,这里查看的时候显示安装了 510
版本的驱动。NVIDIA-SMI 510.68.02 Driver Version: 510.68.02 CUDA Version: 11.6,而正因为这个原因,我后面安装
CUDA 采用 deb 本地安装方式才一直失败,因为该安装方式 CUDA
会自动给你选择安装一个显卡驱动,导致新安装的驱动需要覆写旧的驱动的某些位置,然而虚拟镜像没有权限也不能够覆写主机的一些位置,导致一致出现了unable to make backup link of
的错误,导致新 driver 的某些依赖安装不上,导致一些 cuda、driver
的依赖不满足。
进入 cuDNN
Archive | NVIDIA Developer,选择与 CUDA 版本对应 CuDNN,我这里因为是
CUDA 11.3 因此选择最新的 cuDNN v8.4.0 (April 1st, 2022), for CUDA
11.x,然后选择
Local Installer for Linux x86_64 (Tar)
注意:我选择使用 Local Installer for Ubuntu20.04 x86_64 (Deb)
的时候没安装好,后面使用 tar 安装才安装好。
当你选好之后,点击应该会让你注册才能够获得下载链接,注册就好.然后安装如下:
1 2 3 4 5 6 7 8
# 下载 cuDNN,并解压 wget url cudnn.tar.xz tar -xvf cudnn.tar.xz
ubuntu@e2ac535b1b1f:~$ sudo apt install nvidia-compute-utils-515 nvidia-utils-515 Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: nvidia-compute-utils-515 nvidia-utils-515 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. 45 not fully installed or removed. Need to get 608 kB of archives. After this operation, 1966 kB of additional disk space will be used. Get:1 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64 nvidia-compute-utils-515 515.43.04-0ubuntu1 [271 kB] Get:2 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64 nvidia-utils-515 515.43.04-0ubuntu1 [337 kB] Fetched 608 kB in 1s (998 kB/s) debconf: delaying package configuration, since apt-utils is not installed (Reading database ... 92572 files and directories currently installed.) Preparing to unpack .../nvidia-compute-utils-515_515.43.04-0ubuntu1_amd64.deb ... Unpacking nvidia-compute-utils-515 (515.43.04-0ubuntu1) ... dpkg: error processing archive /var/cache/apt/archives/nvidia-compute-utils-515_515.43.04-0ubuntu1_amd64.deb (--unpack): unable to make backup link of './usr/bin/nvidia-cuda-mps-control' before installing new version: Invalid cross-device link dpkg-deb: error: paste subprocess was killed by signal (Broken pipe) Preparing to unpack .../nvidia-utils-515_515.43.04-0ubuntu1_amd64.deb ... Unpacking nvidia-utils-515 (515.43.04-0ubuntu1) ... dpkg: error processing archive /var/cache/apt/archives/nvidia-utils-515_515.43.04-0ubuntu1_amd64.deb (--unpack): unable to make backup link of './usr/bin/nvidia-debugdump' before installing new version: Invalid cross-device link dpkg-deb: error: paste subprocess was killed by signal (Broken pipe) Do you want to continue? [Y/n] 0% [Working] Get:1 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64 nvidia-compute-utils-515 515.43.04-0ubuntu1 [271 kB] Get:2 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64 nvidia-utils-515 515.43.04-0ubuntu1 [337 kB] Fetched 608 kB in 1s (1000 kB/s) debconf: delaying package configuration, since apt-utils is not installed (Reading database ... 50% (Reading database ... 95% (Reading database ... 92572 files and directories currently installed.) Preparing to unpack .../nvidia-compute-utils-515_515.43.04-0ubuntu1_amd64.deb ... Unpacking nvidia-compute-utils-515 (515.43.04-0ubuntu1) ... dpkg: error processing archive /var/cache/apt/archives/nvidia-compute-utils-515_515.43.04-0ubuntu1_amd64.deb (--unpack): unable to make backup link of './usr/bin/nvidia-cuda-mps-control' before installing new version: Invalid cross-device link dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../nvidia-utils-515_515.43.04-0ubuntu1_amd64.deb ... Unpacking nvidia-utils-515 (515.43.04-0ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/nvidia-utils-515_515.43.04-0ubuntu1_amd64.deb (--unpack): unable to make backup link of './usr/bin/nvidia-debugdump' before installing new version: Invalid cross-device link dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing: /var/cache/apt/archives/nvidia-compute-utils-515_515.43.04-0ubuntu1_amd64.deb /var/cache/apt/archives/nvidia-utils-515_515.43.04-0ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
ubuntu@e2ac535b1b1f:~$ sudo apt remove cuda-drivers nvidia-driver-515 cuda-drivers-515 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-runtime-11-3 : Depends: cuda-drivers (>= 465.19.01) but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). ubuntu@e2ac535b1b1f:~$ sudo apt remove cuda-drivers nvidia-driver-515 cuda-drivers-515 cuda-runtime-11-3 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-11-3 : Depends: cuda-runtime-11-3 (>= 11.3.1) but it is not going to be installed cuda-demo-suite-11-3 : Depends: cuda-runtime-11-3 but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
A new initrd image has also been created. To revert, please regenerate your initrd by running the following command after deleting the modprobe.d file: `/usr/sbin/initramfs -u`
***************************************************************************** *** Reboot your computer and verify that the NVIDIA graphics driver can *** *** be loaded. *** *****************************************************************************
INFO:Enable nvidia DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here dependency problems - leaving unconfigured Processing triggers for mime-support (3.64ubuntu1) ... Processing triggers for gnome-menus (3.36.0-1ubuntu1) ... Processing triggers for libc-bin (2.31-0ubuntu9.9) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for dbus (1.12.16-2ubuntu2.2) ... Processing triggers for desktop-file-utils (0.24-1ubuntu3) ... Errors were encountered while processing: cuda-toolkit-11-3-config-common libnvjpeg-11-3 libnvjpeg-dev-11-3 cuda-cudart-11-3 cuda-cudart-dev-11-3 cuda-libraries-dev-11-3 libnpp-11-3 libcusparse-11-3 libcurand-11-3 cuda-visual-tools-11-3 libcufft-11-3 libcusparse-dev-11-3 libcusolver-11-3 cuda-cupti-11-3 libcublas-11-3 cuda-samples-11-3 libcurand-dev-11-3 libcublas-dev-11-3 cuda-nvcc-11-3 libnpp-dev-11-3 cuda-libraries-11-3 cuda-documentation-11-3 cuda-compiler-11-3 cuda-cupti-dev-11-3 cuda-toolkit-11-3 libcufft-dev-11-3 libcusolver-dev-11-3 cuda-tools-11-3 cuda-command-line-tools-11-3 E: Sub-process /usr/bin/dpkg returned an error code (1)