导读
本文将介绍如何在Ubuntu系统上,安装显卡驱动。
1. 下载驱动
驱动程序下载[1]打开上面的驱动下载链接,根据自己的显卡型号进行选择对应配置,如下图,后点击搜索。
驱动下载
下载搜索后,点击下面下载案例即可下载。
下载
2. 安装依赖
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compilersudo apt-get install --no-install-recommends libboost-all-devsudo apt-get install libopenblas-dev liblapack-dev libatlas-base-devsudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev如果安装失败,则先进行pip3的升级更新,再重复上述操作。
sudo apt-get install python3-pip更新升级pip3:sudo pip3 install --upgrade pip3. 禁用系统默认显卡驱动
sudo gedit /etc/modprobe.d/blacklist.conf # 在文件末尾写入blacklist nouveauoptions nouveau modeset=0 # 保存后手动更新;sudo update-initramfs -u # 电脑重启,输入下列指令进行确认,若无输出,则禁用成功:lsmod | grep nouveau4. 配置环境变量
gedit命令打开配置文件sudo gedit ~/.bashrc末尾写入export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATHexport LD_LIBRARY_PATH=/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH保存更新source ~/.bashrc5. 卸载原有驱动
sudo apt-get --purge remove nvidia*sudo apt autoremove6. 退出图形界面
按住ctrl+alt+F1(1-6均可),进入x-serversudo service lightdm stop如果提示unit lightdm.service not loaded则需要安装LightDm:
sudo apt install lightdm安装完毕后跳出一个界面,选择lightdm,再sudo service lightdm stop。
7. 安装驱动
sudo chmod +x NVIDIA-……………….run*sudo sh NVIDIA-……………….run* --no-opengl-files --no-x-check --no-nouveau-check # –no-opengl-files 不安装OpenGL文件# –no-x-check 安装驱动时不检查X服务,非必需。# –no-nouveau-check 安装驱动时不检查nouveau,此参数非必需,因为之前已经手动禁用了nouveau。安装过程中选项如下:
1.The distribution-provided pre-install script failed! Are you sure you want to continue? “Yes”2.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”3.Nvidia’s 32-bit compatibility libraries?“No”4.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”挂载NVIDIA驱动:modprobe nvidia回到图形界面或直接将电脑重启sudo service lightdm start #回到图形界面sudo reboot now #重启终端输入指令sudo nvidia-smi参考资料
[1]驱动下载: https://www.nvidia.cn/Download/index.aspx?lang=cn