/ How to switch the primary GPU to NVIDIA on Wayland for KDE Plasma and GNOME

How to switch the primary GPU to NVIDIA on Wayland for KDE Plasma and GNOME

2025. 1. 13. 오전 12:41:36
Linux 사용자들이 기본적으로 사용하는 Wayland에서 NVIDIA GPU로 기본 그래픽 카드를 변경하는 방법을 안내한 기사입니다. GNOME과 KDE Plasma 환경에서 NVIDIA GPU를 기본으로 설정하는 단계를 설명하며, udev 규칙을 사용하여 이전에 언급된 문제를 해결할 수 있습니다.
How to switch the primary GPU to NVIDIA on Wayland for KDE Plasma and GNOME
There is no duplication or untranslated content in the provided text. Here's the complete translation result while maintaining the HTML structure: ```html

Most distributions use the computer's built-in GPU (e.g., AMD or Intel) by default, so this tutorial includes a quick guide to switch the primary GPU from Wayland to an NVIDIA GPU.

This tutorial was tested in the most popular Linux desktop environments used by the most popular Linux users - GNOME and KDE Plasma. However, if another desktop environment uses KWin as its compositor or Mutter as its window manager for GNOME, this tutorial should also work.

This tutorial is recommended for people using Wayland by default. If you want to change an X11/Xorg session or switch the primary GPU to an NVIDIA GPU, please refer to my tutorial on "How to Connect External Monitors to Your Linux Laptop (Solving HDMI 'No Signal' Issues)".

The basic requirement is either passing environment variables or setting up udev rules. However, first, run the following command in your favorite terminal emulator to check which GPU your system is currently using:

glxinfo | egrep "OpenGL vendor|OpenGL renderer"

Switching the Default GPU to NVIDIA in GNOME

For the GNOME desktop environment, you need to create a new file named 61-mutter-primary-gpu.rules in the /etc/udev/rules.d/ directory. To do this, run the following command in your favorite terminal app (using GNU nano editor or your preferred command-line editor if installed):

sudo nano /etc/udev/rules.d/61-mutter-primary-gpu.rules

This command will create a 61-mutter-primary-gpu.rules file and open it with GNU nano, where you can paste the following udev rule to switch the primary GPU to NVIDIA. However, not all distributions have /usr/lib/udev/rules.d directory, so adjust the command accordingly to find the correct directory.

ENV{DEVNAME}=="/dev/dri/card0", TAG+="mutter-device-preferred-primary"

In the above udev rule, /dev/dri/card0 refers to the NVIDIA GPU in your system. To check the location of the GPU, run the following command in your terminal emulator. The first command shows each GPU's PCI number (e.g., card0 is 01:00.0, card1 is 05:00.0, etc.).

ls -l /dev/dri/by-path/

The second command can be used to identify which GPU based on the PCI number is a card0. Therefore, by running these two commands, we know that the NVIDIA GPU has a PCI number of 01:00.0 and is referred to as card0.

lspci -k | grep -EA3 'VGA|3D|Display'

Switching the Default GPU to NVIDIA in KDE Plasma

For the KDE Plasma desktop environment, you need to create a directory named .config/environment.d/. Additionally, you need to create a file named 90-nvidia.conf within this directory. Run the following commands: The first command creates the directory, and the second command creates the configuration file.

mkdir ~/.config/environment.d/
nano ~/.config/environment.d/90-nvidia.conf

Now, paste the following line into the environment.d/90-nvidia.conf file, save it, and close nano:

__NV_PRIME_RENDER_OFFLOAD=1
__GLX_VENDOR_LIBRARY_NAME=nvidia
__VK_LAYER_NV_optimus=NVIDIA_only

That's it. Now reboot your computer to set the NVIDIA graphics card as the primary GPU in Wayland. You can check this through the command line or by using a system settings app to confirm that the graphics card is an NVIDIA one.