CentOS 7 install NVIDIA graphics driver and CUDA driver (self-test available)

Learn from the blog: address

1. Install NVIDIA graphics driver

1. Shield nouveau driver

编写(如果没有会新建),下面两个文件
# vi /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
# vi /lib/modprobe.d/nvidia-installer-disable-nouveau.conf
在两个文件下写入如下内容
blacklist nouveau
options nouveau modeset=0

2. Redo the initramfs image

① Make a backup of the current image

cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak

②Create a new mirror

dracut /boot/initramfs-$(uname -r).img $(uname -r)

③Restart

reboot

3. Pre-installed components (networking)

yum install gcc kernel-devel kernel-headers

Insert picture description here
4. Download the official NVIDIA driver according to the current system kernel.
Address: https://www.nvidia.cn/Download/index.aspx?lang=cn#
5. Install the NVIDIA driver and
perform the following installation steps. The kernel source path must be specified, otherwise An error will be reported; the version of the kernel is related to the system kernel, there may be differences
①Locate to the directory where the driver is downloaded
②Execute

./NVIDIA-Linux-x86_64-450.66.run --kernel-source-path=/usr/src/kernels/3.10.0-1127.19.1.el7.x86_64  -k $(uname -r)

Description:

  1. NVIDIA-Linux-x86_64-450.66.run is the downloaded driver;

  2. 3.10.0-1127.19.1.el7.x86_64 is the system kernel source code viewed through the ll /usr/src/kernels/ command
    Insert picture description here
    6, installation and decompression

Verifying archive integrity... OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81.......................................
..................................................................
..................................................................

Regular selection

Install 32-bit compatibility library -yesInsert picture description here

PS: Most of the default options are fine, some are options for post-interaction with NVIDIA, and the default is fine.

7. Verification
execution:

lspci |grep NVIDIA
nvidia-smi

The following effects indicate successful installationInsert picture description here

Second, install the CUDA driver

1. Download the CUDA
address: https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=CentOS&target_version=7&target_type=rpmnetwork
According to the provided address, download to the local
Insert picture description here
2. Installation
Installation execution:

./cuda_11.0.3_450.51.06_linux.run

At this time, there may be insufficient permissions, and authorization is required. Here I directly give the highest permissions

chmod 777 cuda_11.0.3_450.51.06_linux.run

After the agreement appears, choose to accept:
Insert picture description here
Installation:
There is no need to install the graphics card driver (the screenshot here is wrong) and
Insert picture description here
a warning message appears, which has no effect on the installation.
Insert picture description here
Screenshot log:

[root@host83 masr]# sudo sh cuda_11.0.3_450.51.06_linux.run
===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-11.0/
Samples:  Installed in /root/, but missing recommended libraries

Please make sure that
 -   PATH includes /usr/local/cuda-11.0/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-11.0/lib64, or, add /usr/local/cuda-11.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.0/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least .00 is required for CUDA 11.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run --silent --driver

Logfile is /var/log/cuda-installer.log

You can also enter the log to view (location is as follows):

 /var/log/cuda-installer.log

3. Configure environment variables

vi /etc/profile

Enter the file, add configuration

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

Make environment variables take effect immediately

source /etc/profile ;

Insert picture description here
The installation is complete!

If you help, remember to like it~

Guess you like

Origin blog.csdn.net/weixin_42656358/article/details/108772841