1 安裝必要依賴
sudo apt-get update
sudo apt-get install g++
sudo apt-get install gcc
sudo apt-get install make
2 卸載原有的驅(qū)動(dòng)
服務(wù)器可能會自帶有驅(qū)動(dòng)貌亭,需要先卸載干凈
sudo apt-get remove nvidia-*
3 禁用 nouveau 驅(qū)動(dòng)
Ubuntu系統(tǒng)集成的顯卡驅(qū)動(dòng)程序是nouveau,它是第三方為NVIDIA開發(fā)的開源驅(qū)動(dòng)揭北,我們需要先將其屏蔽才能安裝NVIDIA官方驅(qū)動(dòng)扳炬。 如果我們直接安裝驅(qū)動(dòng)的話,往往會報(bào)錯(cuò):ERROR: The Nouveau kernel driver is currently in use by your system. This driver is incompatible with the NVIDIA driver搔体。
3.1 打開配置文件
sudo vim /etc/modprobe.d/blacklist-nouveau.conf
3.2 向打開的文件中寫入下面的內(nèi)容:
blacklist nouveau
options nouveau modeset=0
3.3 更新系統(tǒng)
sudo update-initramfs -u
3.4 重啟系統(tǒng)
reboot
3.5 驗(yàn)證是否禁用成功
lsmod | grep nouveau
4 安裝Ubuntu驅(qū)動(dòng)
4.1 查看可安裝Ubuntu驅(qū)動(dòng)列表
sudo ubuntu-drivers devices
image.png
4.2 安裝指定驅(qū)動(dòng)
選擇帶有“recommended”標(biāo)記的驅(qū)動(dòng)程序即可恨樟,更高版本的是最新版,可能存在兼容問題嫉柴。
sudo apt-get install nvidia-driver-535
5 下載NVIDIA顯卡驅(qū)動(dòng)
5.1 查看顯卡版本
lspci | grep -i vga
結(jié)果顯示厌杜,我的顯卡是是2080Ti,所以在NVIDIA官網(wǎng)選擇:
image.png
5.2 把下載的文件傳到服務(wù)器计螺,在服務(wù)器中找執(zhí)行如下指令:
sudo chmod a+x NVIDIA-Linux-x86_64-525.105.17.run
sudo ./NVIDIA-Linux-x86_64-525.105.17.run -no-opengl-files -no-x-check -no-nouveau-check
注:只有禁用opengl這樣安裝才不會出現(xiàn)循環(huán)登陸的問題
-no-x-check:安裝驅(qū)動(dòng)時(shí)關(guān)閉X服務(wù)
-no-nouveau-check:安裝驅(qū)動(dòng)時(shí)禁用nouveau
-no-opengl-files:只安裝驅(qū)動(dòng)文件,不安裝OpenGL文件
6 安裝過程遇到的選項(xiàng)
6.1 An alternate method of installing the NVIDIA driver was detected. (This is usually a package provided by your distributor.) A driver installed via that method may integrate better with your system than a driver installed by nvidia-installer. Please review the message provided by the maintainer of this alternate installation method and decide how to proceed:
選 【continue installation】
6.2 Install NVIDIA's 32-bit compatibility libraries?
選【No】
6.3 Would you like to run the nvidia-xconfig utility to aotumatically update your X configuration file so that the NVIDIA X driver will be used when you restart X?ANy pre-existing X configuration file will be backed up.
選【No】
6.4 Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if your kernel changes later.
選【Rebuild initramfs】
6.5 Would you like to run the nvidia-xconfig utility to automatically update your X configuration file so that the NVIDIA X driver will be used when you restart X? Any pre-existing X configuration file will be backed up.
選【No】
7 驗(yàn)證結(jié)果
nvidia-smi
查看驅(qū)動(dòng)是否安裝完成.png