Deepin20 Beta installs NVIDIA graphics driver and CUDA+CUDNN environment

1. Introduction to Deepin20 Beta and UOS operating system

Deepin20 Beta is a new type of domestic operating system that adopts a unified design style, redesigning from the desktop environment and applications. The underlying warehouse and kernel are upgraded to Debian 10 and Kernel 5.3 respectively. The desktop environment is the most beautiful version of Linux distribution. operating system. For detailed introduction, please refer to the official website: deepin 20 Beta-a new start, coming for you .
The unified operating system UOS is a voluntary initiative initiated by a number of domestic operating system core companies including China Electronics Corporation (CEC), Wuhan Shenzhidu Technology Co., Ltd., Nanjing ArcherMind Technology, and ZTE New Fulcrum. The Chinese domestic operating system jointly created by the operating system preparation team. You can refer to the website: official website .
The purpose of this article is to write this blog post on how to configure a deep learning environment for deepin and UOS operating systems.

2. Install NVIDIA graphics driver

The first thing to do is to disable the Secure Boot option and FastBoot option in the computer startup options, otherwise the system will not be able to boot successfully. Use the ISO burning tool to burn the Deepin operating system to a U disk for installation. After the installation is successful, the next step is to install the NVIDIA graphics driver.

  1. First, install the graphics driver manager in Deepin Store, and switch the graphics driver manager to use the intel default driver (optional). Afterwards, the intel driver may be installed. After the switch is successful, the configuration will be restarted. After seeing the teapot preview icon, click "Use" to enter the system, and then restart the configuration successfully.
    Graphics driver
  2. Uninstall the NVIDIA graphics driver and the Hornet NVIDIA graphics driver in the original deepin system in the system:
sudo apt autoremove nvidia* bumblebee* primus libgl1-nvidia-glx

3. Disable nouveau driver: create a file blacklist.conf:

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

Then add the following content

blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
  1. Update the kernel file, first back up the kernel file, then update the kernel file, restart the operating system
sudo cp /boot/initrd.img-4.19.0.6-amd64 /boot/initrd.img-4.19.0.6-amd64.bak
sudo cp /boot/initrd.img-5.3.0-3-amd64 /boot/initrd.img-5.3.0-3-amd64.bak
sudo update-initramfs -u
sudo shutdown -r now
  1. Check whether the nouveau driver is successfully disabled
lsmod |grep nouveau

If no content is displayed, it means that nouveau driver is successfully prohibited.
Next, there are two ways to install, one is to download the corresponding driver from the official website, the installation process can refer to the author's other blog post Ubuntu installs CUDA and CUDNN tutorial , the other is to use the NVIDIA driver on the deepin source . In fact, installing the graphics card driver is similar to Ubuntu. Now we explain the second installation method. Use apt search to query the NVIDIA driver. So we use apt to download the NVIDIA graphics driver from deepin source and install it

sudo apt-get install nvidia-driver nvidia-smi nvidia-settings nvidia-xconfig
  1. Modify the xorg service configuration After the
    installation is successful, check the BusID of the graphics card in your computer to facilitate configuration:
lspci |egrep "VGA|3D"

As shown below
Graphics driver display, the computer installed by the author here contains two NVIDIA graphics driver and intel graphics driver. What needs to be remembered here is the BusID information of the two devices, which need to be converted, ie "00:02.0->0:2:0,01:00.0->1:0:0", and then modify the xorg configuration file. Friends who are not familiar with it can back up files.

sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak
sudo nano /etc/X11/xorg.conf

Add the following content information at the end of the file

Section "Module"
	Load		"modesetting"
EndSection
Section "Device"
	Identifier		"nvidia"
	Driver			"nvidia"
	BusID			"PCI:1:0:0"
	Option			"AllowEmptyInitialConfiguration"
EndSection

Note: In BusID, you need to replace PCI: x: x: x with the number in front of the NVIDIA graphics card in your computer, and then save the file.

  1. Create a new xorg initialization startup file xinitrc. Create a new file in your home personal folder directory
nano ~/.xinitrc

There should be no need for administrator privileges. If necessary, you can add sudo to perform operations. Add the following content to the file

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
xrandr --dpi 96
  1. Create xorg startup script in lightdm. create a new file
sudo nano /etc/lightdm/display_setup.sh

And write the same content in the file as in the .xinitrc file

#!/bin/bash
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
xrandr --dpi 96

And modify the lightdm configuration file

sudo nano /etc/lightdm/lightdm.conf

Find the line [Seat.*] in the above file, and add the following information below this line

display-setup-script = /etc/lightdm/display_setup.sh

After this is done, restart the operating system so that the NVIDIA graphics driver is installed. Enter nvidia-smi

nvidia-smi

If it can be displayed, it means that the NVIDIA graphics driver can be used.
After the installation is successful, you will encounter the following problems: After the graphics driver is successfully installed, but the graphics driver does not use the NVIDIA graphics driver. This is mainly a problem in the xorg configuration file. The following is the solution. Type in the terminal

nvidia-xconfig

The previous xorg.conf will be backed up as xorg.conf.backup, and then a new xorg.conf file will be generated. Then you can make appropriate modifications to the file in the following form:

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 440.100

Section "ServerLayout"
    Identifier     "Layout0"
    Screen         "nvidia" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section  "Device"
    Identifier	   "intel"
    Driver	   "modesetting"
    BusID	   "PCI:0:2:0"
EndSection
Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection
Section "Screen"
    Identifier     "intel"
    Device         "intel"
    DefaultDepth    24
EndSection
Section "Screen"
    Identifier     "nvidia"
    Device         "nvidia"
    DefaultDepth    24
    Option          "AllowEmptyInitialConfiguration"
EndSection
Section "Module"
    Load            "modesetting"
EndSection
Section "Device"
    Identifier      "nvidia"
    Driver          "nvidia"
    BusID           "PCI:1:0:0"
    Option          "AllowEmptyInitialConfiguration"
EndSection

Restart the system, or restart lightdm, you can see that the nvidia graphics driver file is being used.

3. Install CUDA

  1. Downgrade the GCC compiler. Since the deepin20 beta system source does not have gcc-4.8, g+±4.8, but the operating system is gcc-8, g+±8, so choose to add a source for installation. Here we choose a source of the previous deepin operating system to add:
sudo nano /etc/apt/source.list

Just add the following source

deb [bg-hash=force] https://mirrors.tsinghua.edu.cn/deepin panda main contrib non-free

Then install

sudo apt update
sudo apt-get install gcc-4.8 g++-4.8

Make a soft link to gcc, g++

sudo mv /usr/bin/gcc /usr/bin/gcc.bak
sudo mv /usr/bin/g++ /usr/bin/g++.bak

This will install gcc and g++.

  1. Installing the necessary library files is
    mainly to prevent the same situation as the lack of libraries in the Ubuntu installation CUDA and CUDNN tutorial in the blog post :
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev libgles2-mesa-dev
  1. Install CUDA
    here to download the ubuntu18.04 version of the cuda file directly from the official website for installation. You don't need to install the nvidia graphics driver during the installation process. The installation process is similar to the ubuntu installation process.

However, during the installation process, the author showed a message indicating that the CUDA installation failed. The solution here is to specify the address of the installed library file

sudo bash cuda_10.2.89_440.33.01_linux.run --toolkit --toolkitpath=/usr/local/cuda --librarypath=/usr/local/cuda --smaples --samplespath=$HOME/

If you want to install silently, you only need to add the parameter silent:

sudo bash cuda_10.2.89_440.33.01_linux.run --toolkit --toolkitpath=/usr/local/cuda --librarypath=/usr/local/cuda --smaples --samplespath=$HOME/ --silent

Of course, you can also choose to install to a folder you specify. Then add CUDA to the environment variables of the system

nano ~/.bashrc

Add the following information

CUDA_HOME=/usr/local/cuda
export PATH=$PATH:$CUDA_HOME/bin/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_HOME/lib64

Save the file, and the installation is successful. To test whether the installation is successful, you can use the following command

nvcc -V

4. Install CUDNN

You can download CUDNN from the official website for installation, and then follow the steps below to install

tar -zvxf cudnn-9.0-linux-x64-v7.tgz
cd cuda
sudo cp -P lib64/* /usr/local/cuda/lib64/
sudo cp -P include/* /usr/local/cuda/include/
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Add environment variables

#cudnn
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda

The installation is successful:
nvidia-smiJPG

NvccJPG

reference

[1] Deepin V20 Beta dual graphics card to install NVIDIA driver (Lenovo Savior Y7000)
[2] UOS operating system notebook dual graphics card perfect driver NVIDIA440 driver
[3] CUDA 10.2 installation notes

Guess you like

Origin blog.csdn.net/Zhang_Pro/article/details/107126641
Recommended