As we all know, the graphics card driver of Ubuntu system is an open source graphics card driver. When configuring the Ubuntu deep learning workstation, we usually need to replace the open source graphics card driver with the official driver of NVIDIA.
According to the graphics card configuration of the workstation and the CUDA version required by the project, we also need to switch to the corresponding version of the graphics card driver. However, only a few NVIDIA proprietary drivers can be found in the default software and updates of Ubuntu, which may make it impossible for us to successfully configure the deep learning development environment we want.
In order to solve this problem, let's talk about how to configure the third-party warehouse PPA in the software and update, and install the NVIDIA graphics card driver through the third-party warehouse.
1, Using domestic software sources to accelerate
When sudo apt get update or sudo apt get upgrade is executed in the native Ubuntu system, the command execution speed is often slow. The reason is that many dependent packages are downloaded directly from foreign sources. Here, you can manually set the domestic image. The steps are as follows:
1. Open the sources.list file
sudo gedit /etc/apt/sources.list
2. Empty the contents and add the following sources
# Alibaba cloud source deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse ##Beta source deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse # Source code deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse ##Beta source deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse # Tsinghua University source deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse ##Beta source deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse # Source code deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse ##Beta source deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
3. Update software list
After adding the domestic software source, execute the command to update the software list:
sudo apt-get update
Add third party warehouse PPA
The steps are as follows:
1. Execute the following command to add a third-party warehouse for the graphics card driver:
sudo add-apt-repository ppa:graphics-drivers/ppa
2. Update software list
sudo apt update
2, Disable open source driver nouveau
As mentioned earlier, Ubuntu uses the open source driver nouveau by default. Therefore, you need to disable nouveau before installing NVIDIA driver, as follows:
1. Execute the following two commands in succession
sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf" sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
These two commands will write the configuration of disabling Nouveau in the file / etc/modprobe.d/blacklist-nvidia-nouveau.conf. Of course, you can also directly find this file and write the configuration in the editor (vim or gedit).
2. Then you can execute the following command to verify that the above instructions are input into the file / etc/modprobe.d/blacklist-nvidia-nouveau.conf:
cat /etc/modprobe.d/blacklist-nvidia-nouveau.conf
If the following information is displayed, it indicates that it has been successfully disabled:
blacklist nouveau options nouveau modeset=0
3, Formal installation of NIVDIA driver
1. Uninstall the old NVIDIA driver (if necessary):
sudo apt-get purge nvidia*
2. Add graphics card driver to PPA
sudo add-apt-repository ppa:graphics-drivers sudo apt-get update
3. Find the latest NVIDIA driver
sudo apt-cache search nvidia
4. Check the recommended driver version through the following instructions
ubuntu-drivers devices
5. Open the Ubuntu software in the system, click "software and update" in the upper left corner, click "additional driver", select one of the proprietary drivers, and then click "apply changes". After installation, the system will ask the user to restart. Here, follow the instructions to restart.
6. After successful restart, you can query the details in the settings. If the driver is installed correctly, you should be able to see the relevant information of NVIDIA graphics card.