I recently opened an AI tutorial provided by fastai, and I happened to have an nvidia GPU on my computer. I switched to the built-in graphics card because of the high power consumption temperature. It’s time to realize your value nvidia, come out, baby. Perform call Mantra: dumbfounded after nvidia-settings:
ERROR: NVIDIA driver is not loaded
ERROR: Unable to load info from any available system
(nvidia-settings:317): GLib-GObject-CRITICAL **: 06:42:43.821: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
** Message: 06:42:43.855: PRIME: No offloading required. Abort
** Message: 06:42:43.855: PRIME: is it supported? no
Executing nvidia-smi also reported the same error, the driver is gone, did I uninstall the driver when I switched the graphics card last time, when did the cruel slasher be rooted? I really can’t remember it, so let’s reinstall it first:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-460 #here you need to change appropriately according to the version queried above
sudo apt-get install mesa-common-dev
sudo apt -get install freeglut3-dev
The installation went well, and no problems were found in the installation log after confirming:
tianlang@tianlang:spark$ sudo apt-get install nvidia-driver-460
Reading package list... Done
Analyzing the dependency tree of the package
Reading status information... Done
The following software will be installed at the same time:
libnvidia-cfg1-460 libnvidia-compute-460
libnvidia-compute-460:i386 libnvidia-decode-460
libnvidia-decode-460:i386 libnvidia-encode-460
libnvidia-encode-460:i386 libnvidia-extra-460
libnvidia-fbc1-460 libnvidia-fbc1-460: i386 libnvidia-gl-460
libnvidia-gl-460: i386 libnvidia-ifr1-460
libnvidia-ifr1-460:i386 nvidia-compute-utils-460
nvidia-dkms-460 nvidia-kernel-common-460
nvidia-kernel-source-460 nvidia-utils-460
xserver-xorg-video-nvidia-460
The following packages will be upgraded:
libnvidia-cfg1-460 libnvidia-compute-460
libnvidia-compute-460:i386 libnvidia-decode-460
libnvidia-decode-460:i386 libnvidia-encode-460
libnvidia-encode-460:i386 libnvidia-extra-460
libnvidia-fbc1-460 libnvidia-fbc1-460: i386 libnvidia-gl-460
libnvidia-gl-460: i386 libnvidia-ifr1-460
libnvidia-ifr1-460:i386 nvidia-compute-utils-460
nvidia-dkms-460 nvidia-driver-460 nvidia-kernel-common-460
nvidia-kernel-source-460 nvidia-utils-460
xserver-xorg-video-nvidia-460
21 software packages have been upgraded, and 0 software packages have been newly installed. To uninstall 0 software packages, 4 software packages have not been upgraded.
Need to download a 175 MB archive.
After decompression, 156 kB of additional space will be consumed.
Do you want to continue? [Y/n] Y
Get: 1 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic/main amd64 nvidia-driver-460 amd64 460.67-0ubuntu0~0.18.04.1 [433 kB]
...
Downloaded 175 MB, which took 11 minutes and 55 seconds (245 kB/s)
(Reading database... There are currently 296611 files and directories installed in the system.)
Preparing to unpack.../00-nvidia-driver-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unpacking nvidia-driver-460 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../01-libnvidia-gl-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
...
Removing all DKMS Modules
Done.
Unpacking nvidia-dkms-460 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../04-nvidia-kernel-source-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unpacking nvidia-kernel-source-460 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../05-nvidia-kernel-common-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unpacking nvidia-kernel-common-460 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../06-libnvidia-decode-460_460.67-0ubuntu0~0.18.04.1_i386.deb...
De-configuring libnvidia-decode-460:amd64 (460.56-0ubuntu0.18.04.1)...
Unpacking libnvidia-decode-460:i386 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../07-libnvidia-decode-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unpacking libnvidia-decode-460:amd64 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../08-libnvidia-compute-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unconfiguring libnvidia-compute-460:i386 (460.56-0ubuntu0.18.04.1)...
Unpacking libnvidia-compute-460:amd64 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../09-libnvidia-compute-460_460.67-0ubuntu0~0.18.04.1_i386.deb...
Unpacking libnvidia-compute-460:i386 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../10-libnvidia-extra-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unpacking libnvidia-extra-460:amd64 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../11-nvidia-compute-utils-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unpacking nvidia-compute-utils-460 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../12-libnvidia-encode-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unconfiguring libnvidia-encode-460:i386 (460.56-0ubuntu0.18.04.1)...
Unpacking libnvidia-encode-460:amd64 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../13-libnvidia-encode-460_460.67-0ubuntu0~0.18.04.1_i386.deb...
Unpacking libnvidia-encode-460:i386 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../14-nvidia-utils-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unpacking nvidia-utils-460 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../15-xserver-xorg-video-nvidia-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unpacking xserver-xorg-video-nvidia-460 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../16-libnvidia-ifr1-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unconfigure libnvidia-ifr1-460:i386 (460.56-0ubuntu0.18.04.1)...
Unpacking libnvidia-ifr1-460:amd64 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../17-libnvidia-ifr1-460_460.67-0ubuntu0~0.18.04.1_i386.deb...
Unpacking libnvidia-ifr1-460:i386 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../18-libnvidia-fbc1-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unconfiguring libnvidia-fbc1-460:i386 (460.56-0ubuntu0.18.04.1)...
Unpacking libnvidia-fbc1-460:amd64 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../19-libnvidia-fbc1-460_460.67-0ubuntu0~0.18.04.1_i386.deb...
Unpacking libnvidia-fbc1-460:i386 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Preparing to unpack.../20-libnvidia-cfg1-460_460.67-0ubuntu0~0.18.04.1_amd64.deb...
Unpacking libnvidia-cfg1-460:amd64 (460.67-0ubuntu0~0.18.04.1) to (460.56-0ubuntu0.18.04.1)...
Setting up libnvidia-extra-460:amd64 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-fbc1-460:i386 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-fbc1-460:amd64 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-gl-460:i386 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-gl-460:amd64 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-ifr1-460:amd64 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-ifr1-460:i386 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-compute-460:amd64 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-compute-460:i386 (460.67-0ubuntu0~0.18.04.1)...
Setting up nvidia-kernel-source-460 (460.67-0ubuntu0~0.18.04.1)...
Setting up nvidia-utils-460 (460.67-0ubuntu0~0.18.04.1)...
Setting up nvidia-kernel-common-460 (460.67-0ubuntu0~0.18.04.1)...
update-initramfs: deferring update (trigger activated)
Setting up libnvidia-cfg1-460:amd64 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-decode-460:amd64 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-decode-460:i386 (460.67-0ubuntu0~0.18.04.1)...
Setting up nvidia-compute-utils-460 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-encode-460:amd64 (460.67-0ubuntu0~0.18.04.1)...
Setting up libnvidia-encode-460:i386 (460.67-0ubuntu0~0.18.04.1)...
Setting up xserver-xorg-video-nvidia-460 (460.67-0ubuntu0~0.18.04.1)...
Setting up nvidia-dkms-460 (460.67-0ubuntu0~0.18.04.1)...
update-initramfs: deferring update (trigger activated)
INFO:Enable nvidia
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
Loading new nvidia-460.67 DKMS files...
Building for 4.15.0-141-generic
Building for architecture x86_64
Building initial module for 4.15.0-141-generic
Secure Boot not enabled on this system.
Done.
nvidia:
Running module version sanity check.
- Original module
- This kernel never originally had a module by this name
- Installation
- Installing to /lib/modules/4.15.0-141-generic/extra/
nvidia-modeset.ko:
Running module version sanity check.
Good news! Module version 460.67 for nvidia-modeset.ko
exactly matches what is already found in kernel 4.15.0-141-generic.
DKMS will not replace this module.
You may override by specifying --force.
nvidia-drm.ko:
Running module version sanity check.
- Original module
- This kernel never originally had a module by this name
- Installation
- Installing to /lib/modules/4.15.0-141-generic/extra/
nvidia-uvm.ko:
Running module version sanity check.
Good news! Module version for nvidia-uvm.ko
exactly matches what is already found in kernel 4.15.0-141-generic.
DKMS will not replace this module.
You may override by specifying --force.
depmod...
DKMS: install completed.
...
I restarted the computer during the safety period and summoned nvidia again.
This is a bit weird, ask the gpu administrator to understand the situation:
spark$ sudo gpu-manager
last_boot_file: /var/lib/ubuntu-drivers-common/last_gfx_boot
new_boot_file: /var/lib/ubuntu-drivers-common/last_gfx_boot
can't access /run/u-d-c-nvidia-was-loaded file
can't access /opt/amdgpu-pro/bin/amdgpu-pro-px
Looking for nvidia modules in /lib/modules/4.15.0-141-generic/updates/dkms
Error: can't open /lib/modules/4.15.0-141-generic/updates/dkms
Looking for amdgpu modules in /lib/modules/4.15.0-141-generic/updates/dkms
Error: can't open /lib/modules/4.15.0-141-generic/updates/dkms
Is nvidia loaded? no
Was nvidia unloaded? no
Is nvidia blacklisted? yes
Is intel loaded? yes
Is radeon loaded? no
Is radeon blacklisted? no
Is amdgpu loaded? no
Is amdgpu blacklisted? no
Is amdgpu versioned? no
Is amdgpu pro stack? no
Is nouveau loaded? no
Is nouveau blacklisted? yes
Is nvidia kernel module available? no
Is amdgpu kernel module available? no
Vendor/Device Id: 8086:191b
BusID "PCI:0@0:2:0"
Is boot vga? yes
Vendor/Device Id: 10de:139a
BusID "PCI:1@0:0:0"
can't open /sys/bus/pci/devices/0000:01:00.0/boot_vga
Is boot vga? no
Error: can't access /sys/bus/pci/devices/0000:01:00.0/driver
The device is not bound to any driver.
can't open /sys/bus/pci/devices/0000:01:00.0/boot_vga
can't access /etc/u-d-c-nvidia-runtimepm-override file
can't open /sys/module/nvidia/version
Warning: cannot check the NVIDIA driver major version
Support for runtimepm not detected.
You can override this check at your own risk by creating the /etc/u-d-c-nvidia-runtimepm-override file.
Is nvidia runtime pm supported for "0x139a"? no
Checking power status in /proc/driver/nvidia/gpus/0000:01:00.0/power
Error while opening /proc/driver/nvidia/gpus/0000:01:00.0/power
Is nvidia runtime pm enabled for "0x139a"? no
Skipping "/dev/dri/card0", driven by "i915"
Skipping "/dev/dri/card0", driven by "i915"
Skipping "/dev/dri/card0", driven by "i915"
Found "/dev/dri/card0", driven by "i915"
output 0:
card0-eDP-1
Number of connected outputs for /dev/dri/card0: 1
Does it require offloading? no
last cards number = 2
Has amd? no
Has intel? yes
Has nvidia? yes
How many cards? 2
Has the system changed? No
Intel IGP detected
Desktop system detected
or laptop with open drivers
Nothing to do
As soon as the GPU administrator reported it, I noticed a piece of information that might be useful:
Is nvidia blacklisted? yes
Shielded? Modprobe should do the shielding, so check modprobe:
$ ls /lib/modprobe.d/
aliases.conf
blacklist_linux_4.15.0-137-generic.conf
blacklist_linux_4.15.0-141-generic.conf
blacklist-nvidia.conf
fbdev-blacklist.conf
nvidia-graphics-drivers.conf
systemd.conf
I saw the blacklist-nvidia.conf file. Modprobe really did it. Is it so smooth? The reality is that I checked the /etc/modprobe.d folder for the first time, and no suspicious files were found. Let go of modprobe. I found another lair /lib/modprobe.d folder after searching to no avail. Hey, this kid is still tricky into the three caves.
It took so much effort to find the configuration file that blocks nvidia gpu, and I must not pull it out to show it to the public:
cat /lib/modprobe.d/blacklist-nvidia.conf
# Do not modify
# This file was generated by nvidia-prime
blacklist nvidia
blacklist nvidia-drm
blacklist nvidia-modeset
alias nvidia off
alias nvidia-drm off
alias nvidia-modeset off
Judging from the comment information, this file was generated by nvidia-prime.
delete it:
rm blacklist-nvidia.conf
Note here that you only need to delete the blacklist-nvidia.conf file, don't delete the nvidia-graphics-drivers.conf file, although the name includes nvidia.
Perform the following during the safe period:
sudo update-initramfs -u
Reboot.
This time, we can finally successfully summon NVIDIA, which has become famous with machine learning in recent years:
tianlang@tianlang: spark $ nvidia-smi
Sat Mar 27 07:27:19 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.67 Driver Version: 460.67 CUDA Version: 11.2 |
|-------------------------------+----------------------+----------------------+
| 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 GeForce GTX 950M Off | 00000000:01:00.0 Off | N/A |
| N/A 49C P0 N/A / N/A | 0MiB / 2004MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+