How to switch primary gpu for wayland

Hi
I have a laptop with both, NVIDIA GPU and Intel UHD graphics.
My fedora uses by default Intl UHD

[~ (0) ]$ glxinfo | egrep "OpenGL vendor|OpenGL renderer"
OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) UHD Graphics (CML GT2)

ATM I try to dbbug why Unity 3d doesn’t work on my machine.
I want to make my laptop use dedicated NVIDIA driver (and gpu).
I found some documents about this in google, but they are for X11, and I’m using gnome on wayland.

Fedora does not include the driver by default, but instead the opensource nouveau drivers.

Those are not comparable in speed and hardware utilization, but more trustworthy and integrated.

The NVIDIA drivers are on rpmfusion.org so add their repos and search for tutorials online.

The easiest way to use NVIDIA on Fedora (or Linux in general) is by using an atomic variant. The drivers often break as they are not tested with the many use cases that can happen. On an atomic system you can just reset to the last working version and wait a bit longer with the update.

Fedora cannot include the proprietary NVIDIA drivers in their atomic variants too for legal reasons. The project uBlue fixes that.

So I highly recommend you to try ublue silberblue-nvidia.

If you really want to do it on traditional Fedora Workstation:

  • add rpmfusion
  • install drivers
  • blacklist nouveau drivers with kargs

Here is how ublue does it but read below how to do with dnf

Most of those commands with rpmostree are likely not to work with a system. using dnf.
The instructions at rpmfusion are really clear and easy to follow instead.

After enabling the rpmfusion repo the only command needed for dnf is
sudo dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda which handles everything needed for the nvidia drivers on more than 95% of all user systems that are not rpm-ostree based for package management.

While I realize that you probably use one of the atomic versions, the great majority of users here do not and instructions like that can become very confusing especially to new users.

2 Likes

I’m Ssorry, I think I forgot to highlight that I’ve already installed an official NVIDIA driver from their official website (by .run file, not rpmfusion because rpmfusion version didn’t work for me).
Thte thing is, how to make my laptop prefer nvidia gpu over intel uhd?

You could blocklist the iGPU

sudo cat > /etc/modprobe.d/blocklist-intelgpu.conf <<EOF
blacklist i915
EOF

After a reboot you will either have no GPU or the NVIDIA one

And installing stuff through .run files is really really bad and can likely break your system, at least when an upgrade comes.

thank you for your rply!

You could blocklist the iGPU

thats a very strange solution, but it might work :smile: I’ll try that!

After a reboot you will either have no GPU or the NVIDIA one

just in case, what will happen if the first option happens? :smile: Will I be able to revert this anyhow?

And installing stuff through .run files is really really bad and can likely break your system, at least when an upgrade comes.

I suppose that but rpmfusion didn’t wokr for me at all - it caused more problems than nouveau. I will update carefully and maybe will work…

Just go to TTY and remove that file.

Also the system should be able to use software rendering as a fallback.

What problems did rpmfusion cause?

What problems did rpmfusion cause?

iirc, it caused issues with my dual-monitor setup (I hope I fixed that by adding nvidia_drm.modeset=1 to kernel commandline) but it also caused some random freezes while startup and running my system.

I tried that but it didn’t do anything

[~ (0) ]$ glxinfo | grep -e OpenGL.vendor -e OpenGL.renderer
OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) UHD Graphics (CML GT2)

What is this i915 in your example? how can I find it?

To utilize a dedicated GPU for specific applications, you can set environment variables as follows:

 __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus=NVIDIA_only glxinfo | egrep "OpenGL vendor|OpenGL renderer"

To force your laptop to exclusively use the dedicated GPU, you can follow the method described in this post: Fedora 36: Nvidia as Primary GPU.

I’ve tried this out on KDE, and it worked fine for me. However, I haven’t given it a go on GNOME yet.

i915 is the driver used for almost every intel GPU.
You can see it in several ways.
Some examples are inxi -Gxx, lspci -nnk | grep -iA5 vga, lsmod | grep i915 and others.

that worked, thank you!

1 Like