30秒解决nvidia-smi报错:NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver

(1) Execute the following command to view the local driver

ls -l /usr/src/

The print is as follows, mine is nvidia-srv-470.129.06

drwxr-xr-x  7 root root 4096 5月  24 22:36 linux-headers-5.13.0-44-generic
drwxr-xr-x  7 root root 4096 6月   8 20:26 linux-headers-5.13.0-48-generic
drwxr-xr-x 24 root root 4096 5月  24 22:36 linux-hwe-5.13-headers-5.13.0-44
drwxr-xr-x 24 root root 4096 6月   8 20:26 linux-hwe-5.13-headers-5.13.0-48
drwxr-xr-x  9 root root 4096 5月  29 15:13 nvidia-srv-470.129.06

If there is no driver, update additional drivers. Perform the following two steps:

  1. try direct download
sudo add-apt-repository ppa:graphics-drivers/ppa && sudo apt update

If the following error is reported,

: GPG error: https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64  InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A4B469963BF863C2

Also perform step 2, replacing your own key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys  A4B469963BF863CC

Or execute nvidia-smi, and follow the prompts to download the driver.

(2) Use dkms to install the driver

sudo dkms install -m nvidia -v srv-470.129.06

There will be the following information:

Kernel preparation unnecessary for this kernel.  Skipping...
applying patch disable_fstack-clash-protection_fcf-protection.patch...patching file Kbuild
Hunk #1 succeeded at 82 (offset 11 lines).


Building module:
cleaning build area...
unset ARCH; [ ! -h /usr/bin/cc ] && export CC=/usr/bin/gcc; env NV_VERBOSE=1 'make' -j16 NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=5.13.0-48-generic IGNORE_XEN_PRESENCE=1 IGNORE_CC_MISMATCH=1 SYSSRC=/lib/modules/5.13.0-48-generic/build LD=/usr/bin/ld.bfd modules........
Signing module:
 - /var/lib/dkms/nvidia/srv-470.129.06/5.13.0-48-generic/x86_64/module/nvidia.ko
 - /var/lib/dkms/nvidia/srv-470.129.06/5.13.0-48-generic/x86_64/module/nvidia-uvm.ko
 - /var/lib/dkms/nvidia/srv-470.129.06/5.13.0-48-generic/x86_64/module/nvidia-modeset.ko
 - /var/lib/dkms/nvidia/srv-470.129.06/5.13.0-48-generic/x86_64/module/nvidia-drm.ko
 - /var/lib/dkms/nvidia/srv-470.129.06/5.13.0-48-generic/x86_64/module/nvidia-peermem.ko
Secure Boot not enabled on this system.
cleaning build area...

DKMS: build completed.

nvidia.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.13.0-48-generic/updates/dkms/

nvidia-modeset.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.13.0-48-generic/updates/dkms/

nvidia-drm.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.13.0-48-generic/updates/dkms/

nvidia-uvm.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.13.0-48-generic/updates/dkms/

nvidia-peermem.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.13.0-48-generic/updates/dkms/

depmod...

DKMS: install completed.

(3) Be sure to restart the computer , and then execute to check whether the connection is successful

nvidia-smi
Sat Jun 11 16:48:01 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.129.06   Driver Version: 470.129.06   CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0  On |                  N/A |
|  0%   39C    P8    39W / 350W |    999MiB / 24234MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1207      G   /usr/lib/xorg/Xorg                101MiB |
|    0   N/A  N/A      2353      G   /usr/lib/xorg/Xorg                102MiB |
|    0   N/A  N/A      3089      G   /usr/lib/xorg/Xorg                274MiB |
|    0   N/A  N/A      3215      G   /usr/bin/gnome-shell              145MiB |
|    0   N/A  N/A      3840      G   ...AAAAAAAAA= --shared-files      231MiB |
+-----------------------------------------------------------------------------+

OK, it’s done in 30s, remember to collect it~

Guess you like

Origin blog.csdn.net/SandyoneU1993/article/details/125236173