Okay, let's get your Arch Linux installation configured for hybrid graphics with AMD iGPU and NVIDIA dGPU, and set up for Wayland (with a fallback to Xorg). This is a multi-step process, but we'll break it down clearly.
Important Considerations Before You Begin:
- Backup: It's strongly recommended to create a backup of your system before making significant changes like this. Timeshift is a good option for this. This will allow you to restore your system to its previous state if anything goes wrong.
- UEFI/BIOS: Ensure your UEFI/BIOS is up-to-date. Outdated firmware can sometimes cause issues with hybrid graphics.
- Display Manager: Choose a display manager. Common choices for Wayland are
gdm (GNOME Display Manager), sddm (KDE Plasma Display Manager), or lightdm. gdm is often the easiest to configure for NVIDIA/Wayland out of the box. If you're planning to use GNOME as your desktop environment, then gdm is the natural choice. If you're planning on using KDE Plasma as your desktop environment, then sddm is the natural choice. If you want a lighter display manager, then lightdm is the natural choice.
- Desktop Environment: Your choice of desktop environment (DE) also matters. GNOME and KDE Plasma have the best Wayland support, but other DEs like XFCE are gaining ground.
- Read the Arch Wiki: Seriously, the Arch Wiki is your best friend. Refer to it often. Specifically, read:
Step-by-Step Configuration
-
Identify Your Hardware:
- Open a terminal.
- Run:
lspci | grep -E "VGA|3D"
This will show you your AMD iGPU and NVIDIA dGPU. Note down their models.
-
Install Required Packages:
-
Update your system:
sudo pacman -Syu
-
Install drivers: This is the most crucial step. We'll use the nvidia package directly from the Arch repositories. Also install amdgpu
sudo pacman -S nvidia nvidia-utils amdgpu mesa vulkan-radeon lib32-vulkan-radeon vulkan-icd-loader lib32-vulkan-icd-loader
nvidia: The main NVIDIA driver package.
nvidia-utils: Utilities for managing the NVIDIA driver (e.g., nvidia-smi, nvidia-settings).
amdgpu: The AMD GPU driver.
mesa: The open-source OpenGL implementation, needed for the AMD iGPU.
vulkan-radeon: Vulkan driver for AMD GPUs
lib32-vulkan-radeon: 32 bit vulkan driver for AMD GPUs
vulkan-icd-loader: The vulkan ICD loader, needed to interface with the GPU
lib32-vulkan-icd-loader: 32 bit vulkan ICD loader
-
Install a Display Manager: Choose your display manager (e.g., gdm, sddm, lightdm). I'll use gdm as an example:
sudo pacman -S gdm
sudo systemctl enable gdm.service
If you choose a different DM, replace gdm with the correct package name and service name. Enable the service after installation.
-
Install a Desktop Environment (if you haven't already): If you don't have a DE installed, install one (e.g., GNOME, KDE Plasma, XFCE). I'll assume GNOME:
sudo pacman -S gnome gnome-extra
For KDE Plasma:
sudo pacman -S plasma-meta
For XFCE:
sudo pacman -S xfce4
-
Install optimus-manager (Optional but Recommended): optimus-manager allows you to easily switch between using the iGPU (for power saving) and the dGPU (for performance). It helps manage the PRIME setup.
sudo pacman -S optimus-manager
sudo systemctl enable optimus-manager.service
sudo systemctl start optimus-manager.service
- Important: After installing
optimus-manager, reboot your system.
-
Install nvidia-prime (Alternative to optimus-manager): If you don't want optimus manager, install nvidia-prime.
sudo pacman -S nvidia-prime
-
Configure PRIME (Primary GPU Offload):
PRIME is the technology that allows you to use both GPUs. There are a few ways to configure it:
-
Option 1: optimus-manager (Recommended):
-
Option 2: nvidia-prime:
-
Important: You will need to create an Xorg configuration file. Create /etc/X11/xorg.conf.d/10-nvidia-prime.conf with the following content:
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "PCI:1:0:0" # Replace with your NVIDIA GPU's BusID (find it with `lspci | grep -E "VGA|3D"`)
EndSection
Section "Screen"
Identifier "nvidia"
Device "nvidia"
Option "AllowEmptyInitialConfiguration"
EndSection
-
Find the correct BusID with lspci | grep -E "VGA|3D". The output will be something like 01:00.0 VGA compatible controller: NVIDIA Corporation .... The 01:00.0 is the BusID you need to convert to the PCI:1:0:0 format (hex to decimal, and fill in the zeros).
-
Reboot after creating this file.
-
To run an application on the NVIDIA GPU:
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia your_application
-
You can also set these environment variables globally in your .bashrc or .zshrc file if you always want to use the NVIDIA GPU for a particular user:
export __NV_PRIME_RENDER_OFFLOAD=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia
-
Option 3: Manual Configuration (Advanced): This involves manually creating Xorg configuration files and using xrandr commands. This is more complex and is generally not recommended unless you have a very specific need. Refer to the Arch Wiki for details.
-
Configure Wayland (and Fallback to Xorg):
- Wayland Session:
-
If you installed gdm, it should automatically offer a Wayland session at the login screen.
-
If you installed sddm, you may need to edit /etc/sddm.conf.d/wayland.conf (create it if it doesn't exist) and add the following:
[General]
DisplayServer=wayland
-
If you installed lightdm, you will need to install lightdm-gtk-greeter or a similar greeter and configure it to use a Wayland session. This is more involved and depends on the greeter you choose.
- Testing Wayland:
- Log out and select the Wayland session at the login screen.
- If your desktop environment loads successfully, congratulations!
- If it fails, you will likely be automatically reverted to an Xorg session.
- Troubleshooting Wayland:
- NVIDIA Issues: NVIDIA's Wayland support is still not perfect. You may encounter glitches or compatibility problems. Ensure you are using the latest NVIDIA drivers. Sometimes, older driver versions are more stable.
- Environment Variables: Ensure the environment variables for PRIME are correctly set if you're using
nvidia-prime.
- Xorg Fallback: If Wayland fails repeatedly, you may need to investigate the logs (e.g.,
/var/log/Xorg.0.log, journalctl) to identify the problem. It may be necessary to use Xorg as your primary session until NVIDIA's Wayland support improves.
- Specific Applications: Some applications may not work well under Wayland. You may need to run them with XWayland (a compatibility layer that allows Xorg applications to run under Wayland).
-
Verify Your Setup:
- Check GPU Usage:
- Run
nvidia-smi in a terminal. This will show you the status of your NVIDIA GPU (temperature, memory usage, etc.). If it's not working, the driver is likely not loaded correctly.
- Run
glxinfo | grep "OpenGL renderer" to see which GPU is being used for OpenGL rendering. If running in intel mode, it should say Mesa Intel.... If running in nvidia mode, it should say NVIDIA....
- Test Application Offloading:
- Try running a graphics-intensive application using the offloading command (either
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia your_application or the optimus-manager approach). Monitor the GPU usage with nvidia-smi to confirm that the NVIDIA GPU is being used.
- Monitor Power Consumption: Use tools like
powertop to monitor power consumption and verify that the iGPU is being used when you're not running demanding applications.
Important Notes and Troubleshooting:
- NVIDIA Driver Versions: Sometimes, newer NVIDIA drivers can introduce issues. If you experience problems, try downgrading to a previous driver version.
- Kernel Parameters: In some cases, you may need to add kernel parameters to your bootloader (e.g., GRUB) to improve compatibility. Refer to the Arch Wiki for specific recommendations. Common parameters include:
nvidia-drm.modeset=1 (For enabling modesetting with NVIDIA DRM)
acpi_osi=! acpi_osi='!Windows 2009' (Sometimes helps with ACPI issues on laptops)
- Logs: Check the system logs (e.g.,
/var/log/Xorg.0.log, journalctl) for error messages if you encounter problems.
- Wayland Compositors: Different Wayland compositors (e.g., GNOME's Mutter, KDE Plasma's KWin) have different levels of NVIDIA support and different configuration options. Refer to the documentation for your specific compositor.
- Reboot Frequently: Rebooting after making significant changes is often necessary for the changes to take effect.
- Disable Secure Boot: If you're using Secure Boot, you may need to disable it or sign the NVIDIA kernel modules. This is a more advanced topic.
Example Scenario (Using optimus-manager and GNOME on Wayland):
- Install
nvidia, nvidia-utils, amdgpu, mesa, vulkan-radeon, lib32-vulkan-radeon, vulkan-icd-loader, lib32-vulkan-icd-loader, gdm, gnome, gnome-extra, and optimus-manager.
- Enable
gdm.service and optimus-manager.service.
- Reboot.
- Log in to a GNOME Wayland session.
- Use
optimus-manager switch intel to use the iGPU for power saving.
- Use
optimus-manager switch nvidia to use the dGPU for performance.
- Reboot after switching modes.
- Run
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxgears to test offloading. Monitor with nvidia-smi.
This setup is complex, so be patient and methodical. Consult the Arch Wiki and the NVIDIA documentation frequently. Good luck! Remember to backup your system before making these changes.