NVIDIA Driver 440.33 doesn't recognize the main laptop screen, but good with external displays, Ubun...

I am using Ubuntu 18.04, kernel 4.15.0.76-generic, GPU is Geforce GTX 960 (GM107 chip). I set up Nvidia drivers 440.33.01 with Cuda 10.2 last week, and everything was working perfectly. I believe the issue started after a minor update to either ubuntu (or something else) today. Currently, booting happens on the main laptop screen, but as soon as I login using gdm3, the main laptop screen turns black. (Still can be used for TTY though) Nvidia-smi and related commands work fine.
I purged and reinstalled nvidia drivers and cuda, and without drivers the main laptop screen works fine. (But in this case the external display is not recognized)

sudo lshw -c video
  *-display                 
       description: 3D controller
       product: GM107M [GeForce GTX 960M]
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a2
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list rom
       configuration: driver=nvidia latency=0
       resources: irq:134 memory:a3000000-a3ffffff memory:90000000-9fffffff memory:a0000000-a1ffffff ioport:4000(size=128) memory:a4080000-a40fffff
  *-display
       description: VGA compatible controller
       product: HD Graphics 530
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 06
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:132 memory:a2000000-a2ffffff memory:b0000000-bfffffff ioport:5000(size=64) memory:c0000-dffff

Output of nvidia-smi

nvidia-smi
Wed Feb 12 21:41:22 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.33.01    Driver Version: 440.33.01    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 GTX 960M    On   | 00000000:01:00.0  On |                  N/A |
| N/A   47C    P0    N/A /  N/A |    205MiB /  4043MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1415      G   /usr/lib/xorg/Xorg                            14MiB |
|    0      1534      G   /usr/bin/gnome-shell                          11MiB |
|    0      1932      G   /usr/lib/xorg/Xorg                            89MiB |
|    0      2180      G   /usr/bin/gnome-shell                          81MiB |
|    0      2714      G   /usr/lib/firefox/firefox                       1MiB |

I don’t think I have an hardware issue. Might be related to X, maybe manually editing Xconf may help, but running nvidia-xconfig did not solve the issue.
I will be very grateful if anyone can help, thanks.

I’m just adding a ‘me-too’, but I’ll toss out some other things that may be helpful:

On laptops, which I’m assuming you have though you didn’t post inxi -Fxzd (this is a prerequisite to getting any help on linux), the outputs are actually wired to specific cards. That is, your built-in display is almost always wired to the integrated card, and, if you’re lucky, the external displays will be too.

I’ve been able to experiment with two different versions of the Fx505/705 laptops, and one version has both inputs wired to integrated, so everything works effortlessly (including offloading). The other, which I have now, has your same issue. If the nvidia card is forced off, my main screen works but external outputs don’t. If the nvidia driver is set, as it is now (and on yours), then the main screen is black with a single underscore, but the outputs work.

In old days, supposedly bumblebee helped solve this problem, but can’t be used anymore for reasons I haven’t quite ascertained.

I’ll watch this thread in case you are able to find a fix - I need one too.

Thanks for writing here and teaching me about inxi. I am adding the inxi output just in case if it helps someone to solve the issue. I also posted the same question to stack overflow.
https://unix.stackexchange.com/questions/567307/nvidia-driver-doesnt-recognize-the-main-laptop-screen-but-good-with-external-d
As you said that person mentioned bumblebee, and claimed this is a hardware issue. I honestly do not know, but it is just too sad to spend my youth configuring nvidia drivers…

System:    Host: bigboi Kernel: 4.15.0-76-generic x86_64 bits: 64 gcc: 7.4.0 Desktop: Gnome 3.28.4 (Gtk 3.22.30)
           Distro: Ubuntu 18.04.4 LTS
Machine:   Device: laptop System: HP product: HP Pavilion Notebook v: Type1ProductConfigId serial: N/A
           Mobo: HP model: 820F v: 82.30 serial: N/A UEFI: Insyde v: F.25 date: 12/12/2016
Battery    BAT0: charge: 67.1 Wh 100.0% condition: 67.1/67.1 Wh (100%)
           model: Hewlett-Packard Primary status: Full
           hidpp__0: charge: 60% condition: NA/NA Wh model: Logitech M570 status: Discharging
CPU:       Quad core Intel Core i7-6700HQ (-MT-MCP-) arch: Skylake-S rev.3 cache: 6144 KB
           flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 20736
           clock speeds: max: 3500 MHz 1: 1392 MHz 2: 1493 MHz 3: 1778 MHz 4: 1842 MHz 5: 1915 MHz 6: 1727 MHz
           7: 1848 MHz 8: 1698 MHz
Graphics:  Card-1: Intel HD Graphics 530 bus-ID: 00:02.0
           Card-2: NVIDIA GM107M [GeForce GTX 960M] bus-ID: 01:00.0
           Display Server: x11 (X.Org 1.19.6 ) driver: nvidia Resolution: 1920x1080@60.01hz
           OpenGL: renderer: Mesa DRI Intel HD Graphics 530 (Skylake GT2)
           version: 4.5 Mesa 19.2.8 Direct Render: Yes
Audio:     Card-1 Intel 100 Series/C230 Series Family HD Audio Controller driver: snd_hda_intel bus-ID: 00:1f.3
           Card-2 NVIDIA Device 0fbc driver: snd_hda_intel bus-ID: 01:00.1
           Card-3 Microsoft driver: USB Audio usb-ID: 001-010
           Sound: Advanced Linux Sound Architecture v: k4.15.0-76-generic
Network:   Card-1: Intel Wireless 7265 driver: iwlwifi bus-ID: 08:00.0
           IF: wlo1 state: up mac: <filter>
           Card-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
           driver: r8169 v: 2.3LK-NAPI port: 3000 bus-ID: 09:00.0
           IF: eno1 state: up speed: 100 Mbps duplex: half mac: <filter>
Drives:    HDD Total Size: 2128.4GB (8.0% used)
           ID-1: /dev/sda model: SanDisk_SD8SNAT size: 128.0GB temp: 39C
           ID-2: /dev/sdb model: ST2000LM003_HN size: 2000.4GB temp: 37C
           Optical-1: /dev/sr0 model: hp DVDRW GUD1N rev: MD00 dev-links: cdrom,cdrw,dvd,dvdrw
           Features: speed: 24x multisession: yes
           audio: yes dvd: yes rw: cd-r,cd-rw,dvd-r,dvd-ram state: running
Partition: ID-1: / size: 185G used: 151G (87%) fs: ext4 dev: /dev/sdb4
           ID-2: /boot size: 454M used: 166M (39%) fs: ext4 dev: /dev/sdb3
           ID-3: swap-1 size: 8.00GB used: 0.00GB (0%) fs: swap dev: /dev/sdb5
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   System Temperatures: cpu: 61.0C mobo: N/A
           Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 323 Uptime: 12:56 Memory: 5045.1/15930.2MB Init: systemd runlevel: 5 Gcc sys: 7.4.0
           Client: Shell (bash 4.4.201) inxi: 2.3.56

Not a real solution but manually editing the xorg.conf file at least makes nvidia-drivers work without problem and the laptop screen is working even the external monitor is not attached.

nvidia-xconfig: X configuration file generated by yigit

nvidia-xconfig: version 440.33.01

Section “ServerLayout”
Identifier “Layout0”
Screen 0 “Screen0” 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 “Device0”
Driver “nvidia”
VendorName “NVIDIA Corporation”
BusID “PCI:1:0:0”
EndSection

Section “Screen”
Identifier “Screen0”
Device “Device0”
Monitor “Monitor0”
DefaultDepth 24
SubSection “Display”
Depth 24
EndSubSection
EndSection

Section “Device”
Identifier “intel”
Driver “modesetting”
Option “AccelMethod” “none”
BusID “PCI:0:2:0”
EndSection

Section “Screen”
Identifier “Screen1”
Device “intel”
Monitor “Monitor0”
DefaultDepth 24
SubSection “Display”
Depth 24
EndSubSection
EndSection