Centos安装cuda和驱动

CentOS操作系统上安装 NVIDIA GPU 驱动(CUDA)

检查是否有卡

lspci | grep -i nvidia

如果没有lspci,需要安装
yum whatprovides */lspci
yum -y install pciutils

检查自带驱动是否被禁用(是否需要禁用看下图报错)

lsmod | grep nouveau

若果有输出
打开系统的blacklist
#新建一个配置文件
sudo vim /etc/modprobe.d/blacklist-nouveau.conf
#写入以下内容
blacklist nouveau
options nouveau modeset=0
#保存并退出
:wq
#备份当前的镜像
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
#建立新的镜像
sudo dracut /boot/initramfs-$(uname -r).img $(uname -r)
#重启
sudo reboot
#最后输入上面的命令验证
lsmod | grep nouveau
也可以在sh执行过后,看是否报错,有时候不需要禁用,如遇到以下报错信息,就需要禁用

在这里插入图片描述

安装必要依赖

yum -y install gcc
yum -y install gcc-c++
yum -y install make

不能使用yum,用编译安装见另一篇文档,编译安装gcc

下载cuda

https://developer.nvidia.com/cuda-12-0-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=runfile_local
自己找对应的版本型号

以Linux Ubuntu 20.04 x86_64为例
wget https://developer.download.nvidia.com/compute/cuda/12.0.0/local_installers/cuda_12.0.0_525.60.13_linux.run
下载完成后
sudo sh cuda_12.0.0_525.60.13_linux.run
之后会跳出
End User License Agreement
-------C
NVIDIA Software License Agreement and CUDA Supplement toSoftware License Agreement .
Preface
------
The Software License Agreement in Chapter 1 and the Supplementin Chapter 2 contain license terms and conditions that governthe use of NVIDIA software. By accepting this agreement, youagree to comply with all the terms and conditions applicableto the product(s) included herein.
NVIDIA Driver
Do you accept the above EULA? (accept/decline/quit):
accept
输入accept
CUDA Installer
-[X] Driver
	[X] 450.51.06
+[X] CUDA Toolkit 11.0
 [X] CUDA Samples 11.0
 [X] CUDA Demo Suite 11.0
 [X] CUDA Documentation 11.0
Options
Install
如果输入nvidia-smi有输出表格结果就将Driver取消勾选,如果没有就直接选择install

声明环境变量

vim ~/.bashrc
加入以下命令
export PATH=/usr/local/cuda-11.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.0/lib64:$LD_LIBRARY_PATH

测试

执行nvcc -V 查看版本
nvidia-smi查看驱动
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值