Ubuntu安装NVIDIA 驱动

Ubuntu安装NVIDIA 驱动

1 基础环境

1.1 gcc环境

安装nvidia之前先检查gcc环境是否在12版本以上

(base) root@ai:/home/chen# gcc --version
gcc (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2 显卡驱动安装

2.1 检查驱动版本

ubuntu-drivers devices

在这里插入图片描述

这里可以看到当前服务器最适合的驱动版本,然后去官网下载对应的版本驱动

2.2 禁用默认驱动

这里提供两个编辑命令,不熟悉nano 可使用vi编辑

 sudo nano /etc/modprobe.d/blacklist-nouveau.conf
 sudo vi /etc/modprobe.d/blacklist-nouveau.conf

进入编辑模式,添加以下两行将nouveau加入黑名单,默认不开启

blacklist nouveau
options nouveau modeset=0

在这里插入图片描述

输入以下命令使禁用生效然后重启

sudo update-initramfs -u
sudo reboot

重启后验证,如果回车后无反应,则禁用成功

lsmod | grep nouveau

2.3 下载NVIDIA 驱动

2.3.1 官网下载

下载地址 https://www.nvidia.cn/geforce/drivers/

进入到这个页面后,选择对应的显卡驱动,要跟服务器的驱动版本一致,点击开始搜索

在这里插入图片描述

搜索后会在下方展示这个搜索结果,然后根据2.1选择适合自己的版本,我这里显示适合570版本,就下载对应的驱动就可以了。

在这里插入图片描述

将下载下来的驱动程序上传至服务器

在这里插入图片描述

2.3.2 驱动安装

将驱动文件添加 可执行权限, 根据自己的程序去调整命令

chmod +x NVIDIA-Linux-x86_64-570.86.16.run

执行安装命令

sudo ./NVIDIA-Linux-x86_64-570.86.16.run -no-opengl-files -no-x-check -no-nouveau-check
1.There appears to already be a driver installed on your system (version:
  390.42).  As part of installing this driver (version: 390.42), the existing
  driver will be uninstalled.  Are you sure you want to continue?(选择 Coninue)
                 Continue installation      Abort installation
2. The distribution-provided pre-install script failed!  Are you sure you want
  to continue?(选择 Cotinue)
                 Continue installation      Abort installation
3. Would you like to register the kernel module sources with DKMS? This will
  allow DKMS to automatically build a new module, if you install a different
  kernel later.(这里选 No)
                          Yes                       No  
4. Install NVIDIA's 32-bit compatibility libraries? (这里选 No)
                          Yes                       No  
5. Installation of the kernel module for the NVIDIA Accelerated Graphics Driver 
for Linux-x86_64 (version 390.42) is now complete.
                                       OK

重启服务器

sudo reboot

验证安装,这里表示后续安装CUDA支持的版本

nvidia-smi

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值