3D acceleration not working on Ubuntu (AMD Raven / Nvidia GTX 1050 mobile)

I have a laptop with both AMD Raven and Nvidia GTX 1050 video adapters. I wanted to test the new game mode in Ubuntu 20.04, and noticed that only the AMD Raven actually works. To do the test, I tried launching a terminal and running gxgears, both in a normal way, and then using the “start using dedicated video adapter” (or whatever it really is in English) option in gnome-shell.

Using the standard video adapter (probably the AMD Raven), it works, but slowly.
Using the dedicated video adapter, I get the following:

juloliv@juloliv:~$ glxgears
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 152 (GLX)
Minor opcode of failed request: 3 (X_GLXCreateContext)
Value in failed request: 0x0
Serial number of failed request: 25
Current serial number in output stream: 26

NB: in both cases, I tried launching nvidia-settings and got the following:

juloliv@juloliv:~$ nvidia-settings

ERROR: Unable to load info from any available system

(nvidia-settings:9213): GLib-GObject-CRITICAL **: 12:33:29.270: g_object_unref: assertion ‘G_IS_OBJECT (object)’ failed
** Message: 12:33:29.273: PRIME: No offloading required. Abort
** Message: 12:33:29.273: PRIME: is it supported? no

And then a blank window…

NB: I’m using nvidia-driver-440 installed through Ubuntu’s “additional drivers”.

PS: I also created a bug in Ubuntu’s own bug tracker: https://bugs.launchpad.net/ubuntu/+source/xorg/+bug/1875005

Actually, I’ve just found out that adding “Option “PrimaryGPU” “Yes”” to /usr/share/X11/xorg.conf.d/10-nvidia.conf made the 3D acceleration (and nvidia-settings) work! However, now, I have no way to switch between AMD Raven and GTX: it always uses the GTX.

sudo prime-select intel
work? See:

No, it doesn’t change a thing. Actually, the only way, for me, to switch between AMD and NVIDIA is by enabling / disabling
Option “PrimaryGPU” “Yes” in /usr/share/X11/xorg.conf.d/10-nvidia.conf, and then restarting.

PS: just to be sure, is there a good way to know which adapter is being used? I use nvidia-smi and glxinfo | grep vendor for that, but maybe it’s misleading…

It’s the correct way to check which gpu gets used. When switched to intel mode, the nvidia gpu should normally be powered off and the nvidia drivers are blacklisted. Please run nvidia-bug-report.sh as root and attach the resulting nvidia-bug-report.log.gz file to your post. You will have to rename the file ending to something else since the forum software doesn’t accept .gz files (nifty!).

nvidia-bug-report.log (322.1 KB)

juloliv@juloliv:~$ prime-select query

juloliv@juloliv:~$ glxinfo | grep vendor
server glx vendor string: NVIDIA Corporation
client glx vendor string: NVIDIA Corporation
OpenGL vendor string: NVIDIA Corporation

juloliv@juloliv:~$ nvidia-smi
Tue Apr 28 12:22:58 2020
| NVIDIA-SMI 440.64 Driver Version: 440.64 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 1050 Off | 00000000:01:00.0 Off | N/A |
| N/A 47C P0 N/A / N/A | 238MiB / 2002MiB | 0% Default |

| Processes: GPU Memory |
| GPU PID Type Process name Usage |
| 0 899 G /usr/lib/xorg/Xorg 45MiB |
| 0 1492 G /usr/lib/xorg/Xorg 91MiB |
| 0 1714 G /usr/bin/gnome-shell 86MiB |
| 0 2011 G …quest-channel-token=8737973603273755061 3MiB |
| 0 3804 G evolution 1MiB |

Please try installing bbswitch. Also, please make sure gpu-manager is enabled (sudo systemctl enable gpu-manager) and attach /var/log/gpu-manager.log

Sorry, but i have no idea how to install bbswitch (neither do I know what it’s for, by the way) on Ubuntu 20.04. Could you give me hint, please?

juloliv@juloliv:~$ sudo systemctl enable gpu-manager

juloliv@juloliv:~$ cat /var/log/gpu-manager.log
log_file: /var/log/gpu-manager.log
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 /opt/amdgpu-pro/bin/amdgpu-pro-px
Looking for nvidia modules in /lib/modules/5.4.0-26-generic/updates/dkms
Found nvidia module: nvidia-modeset.ko
Looking for amdgpu modules in /lib/modules/5.4.0-26-generic/updates/dkms
Is nvidia loaded? yes
Was nvidia unloaded? no
Is nvidia blacklisted? yes
Is intel loaded? no
Is radeon loaded? no
Is radeon blacklisted? no
Is amdgpu loaded? yes
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? yes
Is amdgpu kernel module available? no
Vendor/Device Id: 10de:1c92
BusID “PCI:1@0:0:0”
Is boot vga? no
Vendor/Device Id: 1002:15d8
BusID “PCI:5@0:0:0”
Is boot vga? yes
Skipping “/dev/dri/card1”, driven by “nvidia-drm”
Found “/dev/dri/card0”, driven by “amdgpu”
output 0:
Number of connected outputs for /dev/dri/card0: 1
Skipping “/dev/dri/card1”, driven by “nvidia-drm”
Skipping “/dev/dri/card0”, driven by “amdgpu”
Skipping “/dev/dri/card1”, driven by “nvidia-drm”
Skipping “/dev/dri/card0”, driven by “amdgpu”
Skipping “/dev/dri/card1”, driven by “nvidia-drm”
Skipping “/dev/dri/card0”, driven by “amdgpu”
Does it require offloading? no
last cards number = 2
Has amd? yes
Has intel? no
Has nvidia? yes
How many cards? 2
Has the system changed? No
Unsupported discrete card vendor: 10de
Nothing to do

bbswitch is a kernel module to power off the nvidia gpu. Use
sudo apt install bbswitch
to install it.

juloliv@juloliv:~/Sirea$ sudo apt install bbswitch
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package bbswitch

Sorry, but it doesn’t seem that easy on Ubuntu :(

Looks like the gpu-manager was changed again for 20.04 so that they’re also not providing let alone using bbswitch anymore. You could check if disabling nvidia-persistenced (sudo systemctl disable nvidia-persistenced) keeps the modules from loading.
You should stick to the Ubuntu bug report you opened so this whole mess with prime-select, gpu-manager and amd/nvidia combo get fixed.

So, I disabled nvidia-persistenced, and, after a reboot, I was indeed using the AMD driver. Then, I typed “sudo prime-select nvidia”, and, upon the next reboot, I was using the Nvidia driver.

So, this is a great step forward because i can now switch between the AMD and Nvidia driver. But the last thing bothering me now is that I need a reboot after each “prime-select”. Do you know if there is a way to switch drivers without rebooting? Also, what is the “on-demand” prime profile?

PS: sorry for the stupid questions, but I’m just discovering all this…

For driver switching, restarting the Xserver(s) is necessary. Since Gnome is actually running two Xservers (one for user, one for GDM), it’s safer to reboot.
Normally, (now) prime-select has three states:
intel: nvidia gpu off, drivers unloaded, igpu used
nvidia: nvidia gpu on, drivers loaded, set as PrimaryGPU, dgpu used
on-demand: nvidia gpu on, drivers loaded, not set as PrimaryGPU, igpu used

the latter having two use-cases, a) using the nvdia gpu for cuda, or b) have additional config and use render offloading.
For render offload, please see the link I provided at the beginning of this thread.
Those three states doesn’t help you much since prime-select doesn’t work correctly for amd/nvidia so fails to set the PrimaryGPU setting.

OK, thanks. I’ll just wait for Ubuntu to fix this mess now…