当前位置:   article > 正文

Linux服务器上安装CUDA11.2和对应的cuDNN 8.4.0_linux安装cuda

linux安装cuda

一、检查

检查本机是否有CUDA工具包,输入nvcc -V:

如图所示,服务器上有CUDA,但版本为9.1.85,版本过低,因此博主要重装一个新的。

二、安装CUDA

1.查看服务器最高支持的CUDA版本

在命令行输入nvidia-smi查看显卡驱动版本也就是最高支持的CUDA工具包版本。
例如,本机可安装11.7及以下的CUDA工具包:

2.官网下载CUDA安装包

NVIDIA官网选择对应版本的CUDA工具包并选择你的机器配置,我们就选择11.2.0版本下载

在终端执行如下命令:

  1. wget https://developer.download.nvidia.com/compute/cuda/11.2.0/local_installers/cuda_11.2.0_460.27.04_linux.run
  2. sudo sh cuda_11.2.0_460.27.04_linux.run

3.安装CUDA 

如果出现以下提示,选择continue并在下面取消安装驱动即可。

 根据提示一步步安装,手动输入accept确认。

 我们已经有驱动了,这里取消安装驱动,上下键跳转选项,回车键选择是否安装。

因为我服务器上之前安装过CUDA12,所以会出现这个提示。它表示已经找到了一个现有的CUDA Toolkit 11.2安装,并询问用户是否要升级所有组件或者选择要升级的组件。如果用户不想继续安装,可以选择"No, abort installation"来中止安装过程。我这里选择选择Upgrade all

稍作等待,出现以下提示信息就安装好了,可以看到CUDA安装到了/usr/local/cuda-11.2/

 注意看提示 make sure that:  意思是要添加环境变量 

4.配置环境变量

 输入如下指令查看PATH和LD_LIBRARY_PATH中环境变量

echo $PATH
echo $LD_LIBRARY_PATH

查看有无添加上述两个环境变量,若无,则采用如下两种方法添加环境变量 

 法1: 直接运行export命令定义变量【只对当前shell(BASH)有效(临时的)】  

export PATH=$PATH:/usr/local/cuda-11.2/bin
export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64

 法二:在用户目录下的.bashrc文件中增加变量【(永久的)】

sudo vim ~/.bashrc

 点i进入编辑模式,在最后一行输入

  1. export PATH=$PATH:/usr/local/cuda-11.2/bin
  2. export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64

 输入好了按Esc退出编辑模式,然后输入:wq 保存退出就好

 保存好了之后注意,这个时候如果查看环境变量会发现还是没有添加好的,所以我们需要更新一下bashrc文件。更新指令如下:

source ~/.bashrc

输入nvcc -V查看cuda版本

图示为安装成功。 

我出现的问题:

安装了新的cuda后nvcc -V依然显示旧版本

输入nvcc -V任显示旧版本的v9.1

但查看环境路径却已经配好

 解决办法是:
1.执行sudo apt-get remove nvidia-*卸载原驱动。
2.这时候nvcc -V就会显示下方的图片的错误。

3.下载驱动

  • 输入下条命令,查看你的显卡驱动所使用的内核版本
cat /proc/driver/nvidia/version

 可以看出内核版本为515.105.01

  • 输入下条命令,查看电脑驱动
cat /var/log/dpkg.log | grep nvidia

 2022-05-22 06:24:13 upgrade libnvidia-common-470:all 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:24:13 status half-configured libnvidia-common-470:all 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:24:13 status unpacked libnvidia-common-470:all 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:24:13 status half-installed libnvidia-common-470:all 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:24:14 status half-installed libnvidia-common-470:all 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:24:14 status unpacked libnvidia-common-470:all 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:24:14 status unpacked libnvidia-common-470:all 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:24:14 configure libnvidia-common-470:all 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:24:14 status unpacked libnvidia-common-470:all 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:24:14 status half-configured libnvidia-common-470:all 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:24:14 status installed libnvidia-common-470:all 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:25:58 upgrade nvidia-driver-460:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:25:58 status half-configured nvidia-driver-460:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:25:58 status unpacked nvidia-driver-460:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:25:58 status half-installed nvidia-driver-460:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:25:58 status half-installed nvidia-driver-460:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:25:58 status unpacked nvidia-driver-460:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:25:58 status unpacked nvidia-driver-460:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:25:58 configure nvidia-driver-460:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:25:58 status unpacked nvidia-driver-460:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:25:59 status half-configured nvidia-driver-460:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:25:59 status installed nvidia-driver-460:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:30:36 upgrade nvidia-driver-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:30:36 status half-configured nvidia-driver-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:30:36 status unpacked nvidia-driver-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:30:37 status half-installed nvidia-driver-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:30:37 status half-installed nvidia-driver-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:30:37 status unpacked nvidia-driver-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:30:37 status unpacked nvidia-driver-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:30:37 upgrade libnvidia-gl-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:30:37 status half-configured libnvidia-gl-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:30:37 status unpacked libnvidia-gl-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:30:37 status half-configured libnvidia-gl-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:30:37 status half-installed libnvidia-gl-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:00 status half-installed libnvidia-gl-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:00 status unpacked libnvidia-gl-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:00 status unpacked libnvidia-gl-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:01 upgrade libnvidia-gl-470:i386 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:01 status half-configured libnvidia-gl-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:01 status unpacked libnvidia-gl-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:01 status half-installed libnvidia-gl-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:04 status half-installed libnvidia-gl-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:05 status unpacked libnvidia-gl-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:05 status unpacked libnvidia-gl-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:05 upgrade nvidia-dkms-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:05 status half-configured nvidia-dkms-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:38 status unpacked nvidia-dkms-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:38 status half-installed nvidia-dkms-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:39 status half-installed nvidia-dkms-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:39 status unpacked nvidia-dkms-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:39 status unpacked nvidia-dkms-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:39 upgrade nvidia-kernel-source-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:39 status half-configured nvidia-kernel-source-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:39 status unpacked nvidia-kernel-source-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:39 status half-installed nvidia-kernel-source-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:41 status half-installed nvidia-kernel-source-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:41 status unpacked nvidia-kernel-source-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:42 status unpacked nvidia-kernel-source-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:42 upgrade nvidia-kernel-common-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:42 status half-configured nvidia-kernel-common-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:42 status unpacked nvidia-kernel-common-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:42 status half-installed nvidia-kernel-common-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:43 status half-installed nvidia-kernel-common-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:44 status unpacked nvidia-kernel-common-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:44 status unpacked nvidia-kernel-common-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:44 upgrade libnvidia-decode-470:i386 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:44 status half-configured libnvidia-decode-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:44 status unpacked libnvidia-decode-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:44 status half-configured libnvidia-decode-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:44 status half-installed libnvidia-decode-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:44 status half-installed libnvidia-decode-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:45 status unpacked libnvidia-decode-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:45 status unpacked libnvidia-decode-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:45 upgrade libnvidia-decode-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:45 status half-configured libnvidia-decode-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:45 status unpacked libnvidia-decode-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:45 status half-installed libnvidia-decode-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:45 status half-installed libnvidia-decode-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:45 status unpacked libnvidia-decode-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:45 status unpacked libnvidia-decode-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:46 upgrade libnvidia-compute-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:46 status half-configured libnvidia-compute-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:46 status unpacked libnvidia-compute-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:46 status half-configured libnvidia-compute-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:46 status half-installed libnvidia-compute-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:51 status half-installed libnvidia-compute-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:51 status unpacked libnvidia-compute-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:51 status unpacked libnvidia-compute-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:52 upgrade libnvidia-compute-470:i386 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:52 status half-configured libnvidia-compute-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:52 status unpacked libnvidia-compute-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:52 status half-installed libnvidia-compute-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:56 status half-installed libnvidia-compute-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:56 status unpacked libnvidia-compute-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:56 status unpacked libnvidia-compute-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:56 upgrade libnvidia-extra-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:56 status half-configured libnvidia-extra-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:56 status unpacked libnvidia-extra-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:56 status half-installed libnvidia-extra-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:56 status half-installed libnvidia-extra-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:57 status unpacked libnvidia-extra-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:57 status unpacked libnvidia-extra-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:57 upgrade nvidia-compute-utils-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:57 status half-configured nvidia-compute-utils-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:57 status unpacked nvidia-compute-utils-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:57 status half-installed nvidia-compute-utils-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:57 status half-installed nvidia-compute-utils-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:58 status unpacked nvidia-compute-utils-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:58 status unpacked nvidia-compute-utils-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:58 upgrade libnvidia-encode-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:58 status half-configured libnvidia-encode-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:58 status unpacked libnvidia-encode-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:58 status half-configured libnvidia-encode-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:58 status half-installed libnvidia-encode-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:58 status half-installed libnvidia-encode-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:58 status unpacked libnvidia-encode-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:58 status unpacked libnvidia-encode-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:58 upgrade libnvidia-encode-470:i386 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:58 status half-configured libnvidia-encode-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:58 status unpacked libnvidia-encode-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:58 status half-installed libnvidia-encode-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:59 status half-installed libnvidia-encode-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:59 status unpacked libnvidia-encode-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:59 status unpacked libnvidia-encode-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:59 upgrade nvidia-utils-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:59 status half-configured nvidia-utils-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:59 status unpacked nvidia-utils-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:59 status half-installed nvidia-utils-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:59 status half-installed nvidia-utils-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:59 status unpacked nvidia-utils-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:59 status unpacked nvidia-utils-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:59 upgrade xserver-xorg-video-nvidia-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:31:59 status half-configured xserver-xorg-video-nvidia-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:59 status unpacked xserver-xorg-video-nvidia-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:31:59 status half-installed xserver-xorg-video-nvidia-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:00 status half-installed xserver-xorg-video-nvidia-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:00 status unpacked xserver-xorg-video-nvidia-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:00 status unpacked xserver-xorg-video-nvidia-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:00 upgrade libnvidia-ifr1-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:00 status half-configured libnvidia-ifr1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:00 status unpacked libnvidia-ifr1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:00 status half-configured libnvidia-ifr1-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:00 status half-installed libnvidia-ifr1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:00 status half-installed libnvidia-ifr1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:01 status unpacked libnvidia-ifr1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:01 status unpacked libnvidia-ifr1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:01 upgrade libnvidia-ifr1-470:i386 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:01 status half-configured libnvidia-ifr1-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:01 status unpacked libnvidia-ifr1-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:01 status half-installed libnvidia-ifr1-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:01 status half-installed libnvidia-ifr1-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:01 status unpacked libnvidia-ifr1-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:01 status unpacked libnvidia-ifr1-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:02 upgrade libnvidia-fbc1-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:02 status half-configured libnvidia-fbc1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:02 status unpacked libnvidia-fbc1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:02 status half-configured libnvidia-fbc1-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:02 status half-installed libnvidia-fbc1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:02 status half-installed libnvidia-fbc1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:02 status unpacked libnvidia-fbc1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:02 status unpacked libnvidia-fbc1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:02 upgrade libnvidia-fbc1-470:i386 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:02 status half-configured libnvidia-fbc1-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:02 status unpacked libnvidia-fbc1-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:02 status half-installed libnvidia-fbc1-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:02 status half-installed libnvidia-fbc1-470:i386 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:03 status unpacked libnvidia-fbc1-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:03 status unpacked libnvidia-fbc1-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:03 upgrade libnvidia-cfg1-470:amd64 470.103.01-0ubuntu0.18.04.1 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:03 status half-configured libnvidia-cfg1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:03 status unpacked libnvidia-cfg1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:03 status half-installed libnvidia-cfg1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:03 status half-installed libnvidia-cfg1-470:amd64 470.103.01-0ubuntu0.18.04.1
2022-05-22 06:32:03 status unpacked libnvidia-cfg1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:03 status unpacked libnvidia-cfg1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:03 configure nvidia-kernel-common-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:03 status unpacked nvidia-kernel-common-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:03 status half-configured nvidia-kernel-common-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 status installed nvidia-kernel-common-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 configure libnvidia-gl-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:30 status unpacked libnvidia-gl-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 status half-configured libnvidia-gl-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 status installed libnvidia-gl-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 configure libnvidia-gl-470:i386 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:30 status unpacked libnvidia-gl-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 status half-configured libnvidia-gl-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 status installed libnvidia-gl-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 configure libnvidia-fbc1-470:i386 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:30 status unpacked libnvidia-fbc1-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 status half-configured libnvidia-fbc1-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 status installed libnvidia-fbc1-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 configure libnvidia-fbc1-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:30 status unpacked libnvidia-fbc1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 status half-configured libnvidia-fbc1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 status installed libnvidia-fbc1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:30 configure libnvidia-compute-470:i386 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:30 status unpacked libnvidia-compute-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status half-configured libnvidia-compute-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status installed libnvidia-compute-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 configure libnvidia-compute-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:31 status unpacked libnvidia-compute-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status unpacked libnvidia-compute-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status half-configured libnvidia-compute-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status installed libnvidia-compute-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 configure libnvidia-cfg1-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:31 status unpacked libnvidia-cfg1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status half-configured libnvidia-cfg1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status installed libnvidia-cfg1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 configure libnvidia-ifr1-470:i386 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:31 status unpacked libnvidia-ifr1-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status half-configured libnvidia-ifr1-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status installed libnvidia-ifr1-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 configure libnvidia-ifr1-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:31 status unpacked libnvidia-ifr1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status half-configured libnvidia-ifr1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status installed libnvidia-ifr1-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 configure xserver-xorg-video-nvidia-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:31 status unpacked xserver-xorg-video-nvidia-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status half-configured xserver-xorg-video-nvidia-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status installed xserver-xorg-video-nvidia-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 configure libnvidia-extra-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:31 status unpacked libnvidia-extra-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status half-configured libnvidia-extra-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status installed libnvidia-extra-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 configure nvidia-kernel-source-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:31 status unpacked nvidia-kernel-source-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:31 status half-configured nvidia-kernel-source-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 status installed nvidia-kernel-source-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 configure nvidia-utils-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:32 status unpacked nvidia-utils-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 status half-configured nvidia-utils-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 status installed nvidia-utils-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 configure libnvidia-decode-470:i386 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:32 status unpacked libnvidia-decode-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 status half-configured libnvidia-decode-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 status installed libnvidia-decode-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 configure libnvidia-decode-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:32 status unpacked libnvidia-decode-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 status half-configured libnvidia-decode-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 status installed libnvidia-decode-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 configure nvidia-dkms-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:32:32 status unpacked nvidia-dkms-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:32:32 status half-configured nvidia-dkms-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:03 status installed nvidia-dkms-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:03 configure nvidia-compute-utils-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:35:03 status unpacked nvidia-compute-utils-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:03 status half-configured nvidia-compute-utils-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:03 status installed nvidia-compute-utils-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:03 configure libnvidia-encode-470:i386 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:35:03 status unpacked libnvidia-encode-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:03 status half-configured libnvidia-encode-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:03 status installed libnvidia-encode-470:i386 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:03 configure libnvidia-encode-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:35:03 status unpacked libnvidia-encode-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:03 status half-configured libnvidia-encode-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:03 status installed libnvidia-encode-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:03 configure nvidia-driver-470:amd64 470.129.06-0ubuntu0.18.04.1 <无>
2022-05-22 06:35:03 status unpacked nvidia-driver-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:04 status half-configured nvidia-driver-470:amd64 470.129.06-0ubuntu0.18.04.1
2022-05-22 06:35:04 status installed nvidia-driver-470:amd64 470.129.06-0ubuntu0.18.04.1

 可以看到由470.103.01升级到了515.105.01

  • 输入下条命令,查看电脑所有驱动
sudo dpkg --list | grep nvidia-*
  • 卸载现有驱动,重新安装

sudo /usr/bin/nvidia-uninstall
sudo apt-get --purge remove nvidia-*
sudo apt-get purge nvidia*
sudo apt-get purge libnvidia*

 其中第二行可能会出现:

那就按他说的做 

sudo apt autoremove nvidia-*
  • 直到命令不输出任何内容
sudo dpkg --list | grep nvidia-*
  • 查找可用的驱动版本
ubuntu-drivers devices

那我就安装515吧,带有server的是针对没有图形化界面的服务器的。

  • 重新安装
sudo apt-get install nvidia-driver-515 nvidia-settings nvidia-prime

3.然后按照安装cuda的步骤安装后再nvcc -V就可以显示安装的cuda版本信息。

三、安装cuDNN

1.根据安装的CUDA工具包版本在官网选择适合版本的cuDNN,本文安装的CUDA版本是11.2,就选择与之对应的cuDNN v8.4.0,选择Local Installer for Linux x86_64 (Tar)

2. 复制cuDNN库的链接,使用wget下载或者下载到自己电脑之后再传到服务器上。

  • 我的服务器网速有点慢,所以选择先下到自己电脑再传上去,速度很快啊。

 

 3.解压cuDNN文件,并进入解压出的文件夹,拷贝文件到/usr/local/cuda-11.2中

  1. tar -xvf cudnn-linux-x86_64-8.4.0.27_cuda11.6-archive.tar.xz
  2. cd cudnn-linux-x86_64-8.4.0.27_cuda11.6-archive
  3. sudo cp lib/* /usr/local/cuda-11.2/lib64/
  4. sudo cp include/* /usr/local/cuda-11.2/include/
  5. sudo chmod a+r /usr/local/cuda-11.2/lib64/*
  6. sudo chmod a+r /usr/local/cuda-11.2/include/*

 4. 

查看cuDNN版本,旧版本指令为cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A2,新版本有更新,将cuDNN版本信息单拉了一个文件名为cudnn_version.h,所以新版本查看cuDNN版本的命令为cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

 上述教程为这台机器上的所有用户安装了CUDA和cuDNN,我们查看nvcc是否能用。

好的,安装完成。 

参考文章:Failed to initialize NVML: Driver/library version mismatch_failed to initialize nvidia driver-CSDN博客

Linux安装CUDA & 添加环境变量 & 多版本CUDA切换 (软链接)-CSDN博客

【Linux】安装CUDA 11.2 和 cuDNN 8.4.0并检查是否安装成功_linux查看cudnn是否安装成功-CSDN博客

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号