linux下显卡驱动,cuda,cudnn的安装

安装显卡驱动,cuda,cudnn

在这里插入图片描述

通过上表可以发现,如果要使用CUDA11.1,那么需要将显卡的驱动更新至455.23或以上(Linux x86_64环境)。

在这里插入图片描述
我还没有安装显卡驱动

安装显卡驱动

下载驱动,直接去NVIDIA官网下载:https://www.nvidia.cn/Download/index.aspx?lang=cn

在这里插入图片描述在这里插入图片描述
在这里插入图片描述sudo bash NVIDIA-Linux-x86_64-535.54.03.run

在这里插入图片描述在这里插入图片描述在这里插入图片描述

第一个报错

在这里插入图片描述需要禁用nouveau驱动

在开机选项中(22版本用不了)

在这里插入图片描述按e键

在这里插入图片描述在最后加上空格 nomodeset

编辑配置文件

在这里插入图片描述最末尾加上backlist nouveau
在这里插入图片描述更新配置
在这里插入图片描述

重启

22版本的问题:
禁用驱动

安装gcc7的问题:改源

sudo gedit /etc/apt/sources.list

添加:

deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal main universe

在这里插入图片描述

apt-get update
apt-get -y install gcc-7 g++-7

成功安装了gcc和g++:
在这里插入图片描述在这里插入图片描述

如果存在需要配置gcc和g++路径的情况:
使用如下指令:

gedit ~/.bashrc

添加两条语句:

alias gcc='/usr/bin/gcc-7'
alias g++='/usr/bin/g++-7'

更新:

source ~/.bashrc

完成:
述![

然后在继续安装驱动程序:
在这里插入图片描述

sudo bash NVIDIA-Linux-x86_64-535.54.03.run

22版本最后警告信息处理方式:
处理警告

至此,已经完成了22的驱动安装

在这里插入图片描述

第二个报错

这里是针对ubuntu20.0和18的后续安装

ERROR: Unable to find the development tool cc in your path; please make
sure that you have the package ‘gcc’ installed. If gcc is installed
on your system, then please check that cc is in your PATH.

安装gcc7
安装gcc7的参考

然后,安装g++7

Ubuntu版本之高使得本机使用apt源中没有所需的库版本。所以可以尝试将apt源换回官方源。然后apt update再安装g++。

apt update

g++安装报错解决方案参考

sudo apt-get install g++-7

最后,先安装build-essent,即可完成g++7的安装

 sudo apt-get install build-essential

安装g++后依旧显示未安装解决方案

第三个错误

Unable to find a suitable destination to install 32-bit
compatibility libraries. Your system may not be set up for 32-bit
compatibility. 32-bit compatibility files will not be installed; if
you wish to install them, re-run the installation and set a valid
directory with the --compat32-libdir option.

This NVIDIA driver package includes Vulkan components, but no
Vulkan ICD loader was detected on this system. The NVIDIA Vulkan
ICD will not function without the loader. Most distributions
package the Vulkan loader; try installing the “vulkan-loader”,
“vulkan-icd-loader”, or “libvulkan1” package

Unable to determine the path to install the libglvnd EGL vendor
library config files. Check that you have pkg-config and the
libglvnd development libraries installed, or specify a path with
–glvnd-egl-config-path.

https://github.com/KhronosGroup/Vulkan-Headers
https://github.com/KhronosGroup/Vulkan-Loader

这一些报警信息先忽略了

屏幕不显示问题解决方案

在安装驱动的时候,选择使用nvidia优化显示设置的选项卡:

在这里插入图片描述

安装cuda11.1

下载地址
在这里插入图片描述在这里插入图片描述

wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run

sudo sh cuda_11.1.1_455.32.00_linux.run

在这里插入图片描述
在这里插入图片描述
在执行第二条指令:
出错

在这里插入图片描述先安装gcc

sudo apt-get install gcc
sudo sh cuda_11.1.1_455.32.00_linux.run --override

然后继续执行第二条指令安装:


出现问题:
在这里插入图片描述
于是乎,又重新下载了一次cuda11.1
在这里插入图片描述在这里插入图片描述
移动到
在这里插入图片描述

在这里插入图片描述
(之前的cuda文件只有200M,新下载的有3个G,可能安装失败和文件有关系)

然后再继续安装:

在输入第二条命令之后,经过短暂的等待,会出现用户安装界面,其中包括是否选择安装Nvidia显卡驱动

在这里插入图片描述

如果本地已有驱动,可选择不安装(将光标移至Driver,点击Enter即可),之后移至Install处,点击Enter即可进行安装。

在这里插入图片描述
安装成功:
在这里插入图片描述
查看安装的日志文件:
在这里插入图片描述

开始按照说明配置环境变量

Please make sure that
 -   PATH includes /usr/local/cuda-11.1/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-11.1/lib64, or, add /usr/local/cuda-11.1/lib64 to /etc/ld.so.conf and run ldconfig as root

按照说明配置即可:

gedit ~/.bashrc

添加以下内容:

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

更新环境变量的配置,然后查看cuda 版本:

source ~/.bashrc
nvcc -V

在这里插入图片描述
成功安装cuda11.1

安装cudnn

下载地址
在这里插入图片描述
在这里插入图片描述
在cudnn的下载目录执行指令:

tar -xvf cudnn-linux-x86_64-8.7.0.84_cuda11-archive.tar.xz 
sudo cp cudnn-linux-x86_64-8.7.0.84_cuda11-archive/include/cudnn*.h /usr/local/cuda/include
sudo cp -p cudnn-linux-x86_64-8.7.0.84_cuda11-archive/lib/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

验证安装是否成功:

cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

在这里插入图片描述

显卡驱动参考
nvida 驱动下载地址

nvida 驱动下载方法

安装cuda11.1和pytorch1.8

  • 1
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值