[HowTo] Use Wayland with proprietary NVIDIA drivers

Difficulty: ★★★☆☆

Wayland does not play well with proprietary drivers. Currently the biggest issue is that NVIDIA does currently not support Xwayland properly, so apps that require it get software rendering. This includes most games, which are the most common use case for proprietary NVIDIA drivers. This is why GNOME automatically disables Wayland if you have NVIDIA.

However, if this does not deter you, you can use Wayland with NVIDIA drivers. Here is how to do it:

:warning: If not using GNOME, skip to DE (Desktop Environment)-agnostic instructions in Step 4 :

  1. Edit the /etc/gdm/custom.conf file and comment out the line WaylandEnable=false. The correct file will then look something like this:

    # GDM configuration storage
    daemon]
    # Uncomment the line below to force the login screen to use Xorg
    #WaylandEnable=false
    
    [security]
    
    [xdmcp]
    
    [chooser]
    
    [debug]
    # Uncomment the line below to turn on debugging
    #Enable=true
    
  2. To force-enable Wayland, disable the udev rule responsible for disabling Wayland in GDM:

    sudo ln -s /dev/null /etc/udev/rules.d/61-gdm.rules
    
  3. kms-modifiers must be enabled through gsettings. This can be done with the following command:

    gsettings set org.gnome.mutter experimental-features '["kms-modifiers"]'
    

    DE(Desktop Environment)-agnostic instructions begin here

  4. Enable modesetting for nvdia drivers. Follow the instructions in the Arch wiki:

    • Add the modules nvidia , nvidia_modeset , nvidia_uvm and nvidia_drm to /etc/mkinitcpio.conf and run the command sudo mkinitcpio -P
    • Add the kernel parameter nvidia-drm.modeset=1 to /etc/default/grub and run the command sudo update-grub
  5. Ensure xorg-xwayland, libxcb and egl-wayland are installed:

    sudo pacman -Syu --needed xorg-xwayland libxcb egl-wayland
    
  6. Reboot

  7. Profit. Congratulations, you should now be running GNOME with Wayland despite proprietary NVIDIA drivers!


Additional references:
20 Likes

It is being worked on here

But its way above my head and no idea how long or if it will ever be a viable option

I know, I’m hoping it gets finished soon.

1 Like

Shouldn’t this be better uncommented? :wink:

Wayland for Nvidia drivers is disabled using udev rules

/usr/lib/udev/rules.d/61-gdm.rules

commenting the below line works for me

# disable Wayland when using the proprietary nvidia driver
DRIVER==“nvidia”, RUN+="/usr/lib/gdm-disable-wayland"

What are the benefits using Wayland on KDE?

No idea. This guide will not work with kde, it is for gnome specifically. Also, unlike gnome, kde is not necessarily usable on wayland.

If you have issues. try this without the grub param… Worked a treat for me with the other bits (Ubuntu 21.04 K5.11.11)

Since updating to the Nvidia 495.44 drivers (now in Stable) one thing I noticed is that the contents of 61-gdm.rules in that howto are pretty different to how that file looks now. It looks like there is now logic in there to detect the nvidia driver version number and only disable wayland if the version is lower than 470. However on my system with 495, Wayland does not seem to be an option on the GDM sessions list. So at the very least the instructions here might need to be updated. (and i can’t comment directly in that thread because it got locked)

1 Like

Yep, noticed that, too. I haven’t gotten around to updating the tutorial. In theory my system meets the criteria to use Wayland by default, but logs show some condition wasn’t met, but doesn’t say what.

1 Like

For now, I commented it out and it works in Wayland.

LABEL="gdm_prefer_xorg"
# RUN+="/usr/lib/gdm-runtime-config set daemon PreferredDisplayServer xorg"
GOTO="gdm_end"

LABEL="gdm_disable_wayland"
# RUN+="/usr/lib/gdm-runtime-config set daemon WaylandEnable false"
GOTO="gdm_end"

1 Like

So after the stable update, I noticed I was back on X11. Came back to this post, checked all the settings and also noticed the gdm.rules had changed a lot as @JPL mentioned.

Implemented the above fix and am now back on Wayland but it kind of feels strange. With all the Wayland progress and with the fixes 495 driver brings, shouldn’t Wayland just work without a hacky “comment these lines” fix?

I feel like there has to be a better way :thinking:

inxi output related to my machine and graphics:

Machine:
  Type: Laptop System: Dell product: Precision 5540 v: N/A serial: <filter>
  Chassis: type: 10 serial: <filter>
  Mobo: Dell model: 0FMYX6 v: A00 serial: <filter> UEFI: Dell v: 1.10.0
  date: 03/04/2021
Graphics:
  Device-1: Intel CoffeeLake-H GT2 [UHD Graphics 630] vendor: Dell
  driver: i915 v: kernel bus-ID: 00:02.0 chip-ID: 8086:3e9b class-ID: 0300
  Device-2: NVIDIA TU117GLM [Quadro T2000 Mobile / Max-Q] driver: nvidia
  v: 495.44 alternate: nouveau,nvidia_drm bus-ID: 01:00.0 chip-ID: 10de:1fb8
  class-ID: 0302
  Device-3: Microdia Integrated_Webcam_HD type: USB driver: uvcvideo
  bus-ID: 1-12:4 chip-ID: 0c45:6723 class-ID: 0e02
  Display: wayland server: X.org 1.21.1.1 compositor: gnome-shell driver:
  loaded: modesetting unloaded: nvidia alternate: fbdev,nouveau,nv,vesa
  display-ID: 0 resolution: <missing: xdpyinfo>
  OpenGL: renderer: Mesa Intel UHD Graphics 630 (CFL GT2) v: 4.6 Mesa 21.2.5
  direct render: Yes

I had exactly the same experience and I also enabled wayland the same way, but I guess something is missing.
I’ve been reading about how nvidia’s 495 drivers will natively support wayland via GBM instead of EGL streams, but I am not sure this is enabled, as I see the same problems in wayland as before, including some enough rendering problems to not make it ready for use yet IMO.

I’m also using Nvidia drivers 495.46 and after adding the kernel boot parameter for modeset - still no option for gnome on wayland.

See GDM - ArchWiki

What worked for me is commenting out this line:

LABEL="gdm_prefer_xorg"
# RUN+="/usr/lib/gdm-runtime-config set daemon PreferredDisplayServer xorg"
GOTO="gdm_end"

I don’t understand why setting X11 as preferred removes Wayland from the list of available options, perhaps it’s a bug in GDM.

I’m not sure if a gdm package update or something else fixed it, but my system version of 61-gdm.rules with no modifications now properly shows the Wayland option on the login screen. If this is true for other nvidia users as well, that means one less step to enable wayland.

It doesn’t for me, sadly. Also, when I did follow the instructions to use Wayland, Firefox wouldn’t start unless I started in safe mode, and starting it with MOZ_ENABLE_WAYLAND=1 made it start but it crashed and refused to start even with the option when I tried to check “about:support” to make sure it was running on Wayland, heh. Other applications didn’t render properly (Element, a chat client, showed a blank window with just the application background colour) and some GNOME extensions seemed to break, like “Blur my shell”.

After the latest stable update, I rebooted to X11 again.

When I just went through all the steps in the initial post again, all the changes I made in the past seemed to still be there. So I think one of these must have been the reason why it switched back to Wayland after a reboot:

sudo ln -s /dev/null /etc/udev/rules.d/61-gdm.rules
sudo update-grub

Edit: Bookmarking this thread was a smart move on my end because it’s been a lifesaver a couple of times now.

2 Likes

Hi i was wondering if it is possible to undo this, to return to the default setup of KDE, after doing step 4.
It would be great if the tutorial would include info about that when possible to revert it :+1:

I did step 4 a couple days ago, but would like to revert it.