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