Ubuntu安装NVIDIA驱动

  • 前言
  • 一、禁用nouveau驱动
  • 二、驱动下载
  • 三、驱动安装
  • 四、验证

  • 前言

    本文环境:

  • Ubuntu20.04.4(其他版本或其他Linux系统,安装方法基本一致)
  • RTX2060显卡

  • 一、禁用nouveau驱动

    sudo gedit /etc/modprobe.d/blacklist.conf
    

    在终端输入上面命令打开文件,在文件最后如下两行:

    blacklist nouveau
    options nouveau modeset=0
    


    ctrl + s保存退出,然后reboot重启系统,输入下面的命令,没有任何输出时即禁用成功:

    lsmod | grep nouveau
    

    二、驱动下载

    NVIDIA官网根据自身的显卡型号下载驱动:

    三、驱动安装

    1. 同时按下 Ctrl+Alt+F1(或者 F2-F6),进入命令行界面,输入用户名和登录密码(输入密码时不要用右下角的数字按键),然后 cd 进入到驱动文件所在的文件夹;
    2. 关闭图形界面,如果执行失败可能是没有安装lightdm,直接sudo apt install lightdm安装即可:
    sudo service lightdm stop
    
    1. 卸载系统中存在的驱动,如果没有安装过可略过:
    sudo apt-get remove nvidia-*
    
    1. 赋予执行权限
    sudo chmod a+x NVIDIA-Linux-x86_64-470.63.01.run
    
    1. 安装驱动,如果不用opengl就禁用掉,不然后面会有各种问题
    sudo ./NVIDIA-Linux-x86_64-470.63.01.run -no-x-check -no-nouveau-check -no-opengl-files
    
    a)he distribution-provided pre-install script failed! Are you sure you want
    to continue?
    选择 yes 继续。
    b)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 继续
    c)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 继续
    
    1. 安装结束输入下面的命令重启图形界面
    sudo service lightdm start
    

    四、验证

    nvidia-smi
    

    出现下面的信息即安装成功:

    来源:拉面馆子

    物联沃分享整理
    物联沃-IOTWORD物联网 » Ubuntu安装NVIDIA驱动

    发表评论