I can't enable nvidia-gpu with nvidia-prime

I have a Inspiron 7559 laptop, with Nvidia 960M gpu. I installed Ubuntu 16.04 LTS, then installed nvidia drivers and bumblebee and it ran fine. Recently, I upgraded to Ubuntu 18.04 ,installed nvidia 390 drivers,and bumblebee doesn’t work. After a bit of googling, I found out that bumblebee doesn’t play with nice with nvidia-390+ drivers. Here’s a link for reference- [url]https://bugs.launchpad.net/ubuntu/+source/bumblebee/+bug/1758243[/url]

Anyway, I decided to follow the instructions listed here Ubuntu 18.04, Steam and nvidia 390 but I couldn’t get bumblebee to work. I decided to ditch the whole bumblebee thing and to go only with prime-select method of managing graphics. However, when I do prime-select nvidia and reboot, then I run glxspheres I see that it’s still using intel drivers rather than the nvidia one.

I tried a number of things. I purged and reinstalled nvidia and bumblebee several times. I switched back and forth between intel and nvidia several times. I messed around with the grub file but to no avail. No matter what I do, I can’t get the computer to use nvidia graphics.

Currently, my computer doesn’t have any bumblebee. It only has nvidia-415 drivers. Also commands like nvidia-smi shows gpu information, lspci -vnn | grep ‘'’[030[02]]’ lists the GPU, modinfo | nvidia lists a bunch of things, prime-select query lists nvidia.
nvidia-bug-report.log.gz (1.03 MB)

Please run nvidia-bug-report.sh as root and attach the resulting .gz file to your post. Hovering the mouse over an existing post of yours will reveal a paperclip icon.
[url]https://devtalk.nvidia.com/default/topic/1043347/announcements/attaching-files-to-forum-topics-posts/[/url]

I have added the bug report to the original post.

Looks like everything is in place, it just doesn’t work.
How did you install the 415 driver, from ppa? Did you uninstall the .run installer using the --uninstall option before?

I installed from the graphics ppa. The run installer doesn’t even work for me.

I followed the instructions but nothing changed. I can’t get any software to use the discrete card.

Things to try:

  • Switch to intel, reboot, switch back to nvidia, reboot
  • Add
Option   "PrimaryGPU" "true"

inside the outputclass of /usr/share/X11/xorg.conf.d/10-nvidia.conf

  • Try with the v390 driver
  • check if the file /lib/modprobe.d/nvidia-kms.conf exists and change
    modeset=1 to modeset=0
    then run sudo update-initramfs -u

If all fails, try with the xorg.conf from here:
[url]https://devtalk.nvidia.com/default/topic/1022670/linux/official-driver-384-59-with-geforce-1050m-doesn-t-work-on-opensuse-tumbleweed-kde/post/5203910/#5203910[/url]

Adding

Option   "PrimaryGPU" "true"

to the the 10-nvidia.conf file did the trick! The only problem I have is that for certain animations(like the loading animation of the Plasma desktop), it runs too fast with no sort of framelimiting. But as far as I’m concerned, the gpu works as it should. So thank you.

Try with kernel parameter
nvidia-drm.modeset=1
to get vsync.

Oh yeah, enabling v-sync with nvidia-drm.modeset=1 fixed the animation issues. I dont have any problem now.

Just giving my 5 cents here. I had very similar issue myself. Previously I had used bumblebee but now I had decided to move to pure Nvidia. Running:

sudo prime-select nvidia

Did nothing. In order to fix this I purged Bumblebee

sudo apt purge bumblebee

This resulted in black screen during boot which was rather confusing. Eventually I figured that X11 was still trying to use Intel as a device for the screen. I noticed that Intel device configuration was still contained in following file:

cat /usr/share/X11/xorg.conf.d/20-video.conf
Section "Device"
    Identifier  "Intel Graphics" 
    Driver      "intel"
    Option      "Backlight"  "intel_backlight"
EndSection

After moving this file away from the directory, I rebooted my machine. Long behold my laptop started using Nvidia instead of Intel.

$ nvidia-smi 
Sat Sep 18 18:17:59 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.144                Driver Version: 390.144                   |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  NVS 4200M           Off  | 00000000:01:00.0 N/A |                  N/A |
| N/A   55C    P8    N/A /  N/A |    194MiB /   454MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0                    Not Supported                                       |
+-----------------------------------------------------------------------------+