安装需要的依赖:
sudo apt update
sudo apt install dkms build-essential linux-headers-generic
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install build-essential libc6:i386
禁用nouveau驱动
查看是否成功禁用
只要是安装过NVIDIA显卡驱动的,nouveau一般都被禁止了。可以通过命令
lsmod | grep nouveau
查看。如果没有任何输出就是禁用成功了。否则,请参考禁用步骤。
禁用步骤
创建/etc/modprobe.d/blacklist-nouveau.conf文件,你可以通过如下命令:
sudo vi /etc/modprobe.d/blacklist-nouveau.conf
填入以下内容:
blacklist nouveau
options nouveau modeset=0
重新生产kernel initramfs
sudo update-initramfs -u
sudo apt-get remove --purge nvidia*
2. 卸载原有驱动
sudo apt-get remove --purge nvidia*
3. 安装
init 3 (或者sudo service lightdm stop,建议执行 init 3 后再执行一遍 sudo service lightdm stop)
sudo ./NVIDIA-Linux-x86_64-460.67.run (这条命令安装过程可能报错,并且建议NVIDIA官网下载最新的驱动,
如果显卡驱动版本太老,安装过程中会报错)
当输入安装指令时,不要简单地输入 sudo ./NVIDIA-Linux-x86_64-384.111.run,而是输入:
sudo ./NVIDIA-Linux-x86_64-460.67.run --no-x-check -no-nouveau-check -no-opengl-files
显卡驱动建议用最新版本的!!!!
解释:
-no-x-check:安装驱动时关闭X服务
-no-nouveau-check:安装驱动时禁用nouveau
-no-opengl-files:只安装驱动文件,不安装OpenGL文件(也可以安装,但最好加上去,毕竟循环登陆的bug不好受)
这样再reboot,就不会出现循环登录的问题。
sudo service lightdm start
判断显卡驱动是否安装成功
nvidia-smi #输入指令查看显卡信息
注:其中的一些选项如下:
The distribution-provided pre-install script failed! Are you sure you want to continue? 选择 yes 继续。
Would you like to register the kernel module souces with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later? 选择 No 继续。
Nvidia’s 32-bit compatibility libraries? 选择 No 继续。
Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be used when you restart x? Any pre-existing x confile will be backed up. 选择 Yes 继续
****************************************************************************
****************************************************************************
如果sudo ./NVIDIA-Linux-x86_64-460.67.run --no-x-check -no-nouveau-check -no-opengl-files的安装
过程报错:The CC version check failed
The CC version check failed,大概意思是说kernel是由gcc-8构建的,但是编译驱动的gcc确实4.8.5,不兼容。
解决方式如下:
首先查看以下自己电脑上安装的gcc有哪些版本
ls /usr/bin/gcc*
如果gcc版本过低
然后我就尝试了使用gcc-8来安装驱动,安装命令改为以下,然后就解决了CC check failed的问题。(export只是临时变量,并不会改变系统的默认gcc),如果电脑上没有需要的gcc,就需要再安装一个对应的版本,涉及到多版本gcc的安装问题,有很多人踩过这个坑,建议google食用。
更换安装其他gcc自行搜索:
这里已经安装好了gcc8,执行gcc下安装驱动:
sudo export CC=gcc-8 ./NVIDIA-Linux-x86_64-440.100.run -no-x-check -no-nouveau-check -no-opengl-files