NVIDIA driver sometimes does not load - Linux Mint 20

Sometimes when I start, everything seems fine, but the machine is in an 800x600 resolution with no option to change it. Normally the resolution is 1920x1080.

System is an HP Z400, 10 GB RAM, X5687 CPU, GT 1030 nvidia card, one HDMI monitor. There is no mode setting, or second video card or previous video card.

The machine uses legacy boot, no UEFI, and has dual boot Windows 10 and Linux. Windows 10 never has this issue, and the card always works flawlessly.

Interestingly, entering “sudo killall Xorg” locks the screen and when you then log in, you get the right driver and resolution.

More details below.

When everything is working well:
Driver manager shows: nvidia-driver-440 version 440.100-0ubuntu0.20.04.1
Settings, Display shows: LG Electronics 22", resolution 1920x1080.

$ prime-select query
nvidia
(shown in both situations)

$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:03.0/0000:0f:00.0 ==
modalias : pci:v000010DEd00001D01sv00001043sd000085F5bc03sc00i00
vendor : NVIDIA Corporation
model : GP108 [GeForce GT 1030]
driver : nvidia-driver-418-server - distro non-free
driver : nvidia-driver-390 - distro non-free
driver : nvidia-driver-440-server - distro non-free
driver : nvidia-driver-435 - distro non-free
driver : nvidia-driver-440 - distro non-free recommended
driver : xserver-xorg-video-nouveau - distro free builtin
(shown in both situations)

$ xrandr -q
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
DVI-D-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 480mm x 270mm
1920x1080 60.00*+ 59.94 50.00 60.05 60.00 50.04
1680x1050 59.95
1600x900 60.00
1440x900 59.89
1400x1050 59.98
1280x1024 75.02 60.02
1280x800 59.81
1280x720 60.00 59.94 50.00
1152x864 75.00
1024x768 75.03 60.00
800x600 75.00 60.32
720x576 50.00
720x480 59.94
640x480 75.00 59.94 59.93

$ nvidia-smi
Thu Sep 10 20:44:04 2020
±----------------------------------------------------------------------------+
| NVIDIA-SMI 440.100 Driver Version: 440.100 CUDA Version: 10.2 |
|-------------------------------±---------------------±---------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GT 1030 Off | 00000000:0F:00.0 On | N/A |
| 29% 37C P0 N/A / 30W | 1843MiB / 1999MiB | 43% Default |
±------------------------------±---------------------±---------------------+

±----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 1127 G /usr/lib/xorg/Xorg 157MiB |
| 0 1350 G xfwm4 1MiB |
| 0 2884 G /usr/lib/firefox/firefox 1MiB |
| 0 4718 G bin/do-not-directly-run-firestorm-bin 1680MiB |
±----------------------------------------------------------------------------+

$ lspci|grep VGA
0f:00.0 VGA compatible controller: NVIDIA Corporation GP108 [GeForce GT 1030] (rev a1)

~$ inxi -G
Graphics:
Device-1: NVIDIA GP108 [GeForce GT 1030] driver: nvidia v: 440.100
Display: x11 server: X.Org 1.20.8 driver: nvidia
unloaded: fbdev,modesetting,nouveau,vesa resolution: 1920x1080~60Hz
OpenGL: renderer: GeForce GT 1030/PCIe/SSE2 v: 4.6.0 NVIDIA 440.100



But when it does not work you get:
Settings, Display does NOT show the LG monitor (it shows “default” monitor as the only option) and the only available resolution is 800x600.

$ xrandr -q
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 800 x 600, current 800 x 600, maximum 800 x 600
default connected 800x600+0+0 0mm x 0mm
800x600 75.00*

$ nvidia-smi
Fri Sep 11 19:50:31 2020
±----------------------------------------------------------------------------+
| NVIDIA-SMI 440.100 Driver Version: 440.100 CUDA Version: 10.2 |
|-------------------------------±---------------------±---------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GT 1030 Off | 00000000:0F:00.0 Off | N/A |
| 28% 26C P0 N/A / 30W | 0MiB / 1999MiB | 2% Default |
±------------------------------±---------------------±---------------------+

±----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
±----------------------------------------------------------------------------+

$ inxi -G
Graphics:
Device-1: NVIDIA GP108 [GeForce GT 1030] driver: nvidia v: 440.100
Display: x11 server: X.Org 1.20.8 driver: fbdev,modesetting,nouveau
unloaded: vesa resolution: 800x600~75Hz
OpenGL: renderer: llvmpipe (LLVM 10.0.0 128 bits) v: 3.3 Mesa 20.0.8
bad-nvidia-bug-report.log.gz (226.4 KB) [good-)