Multi-GPU
General
If your host machine uses multiple GPUs, you may want to use one GPU for rendering all the elements for Hyprland including windows, animations, and another for hardware acceleration for certain applications, etc.
This setup is very common in the likes of gaming laptops, GPU-passthrough (without VFIO) capable hosts, and if you have multiple GPUs in general.
Detecting GPUs
For this case, the writer is taking the example of their laptop.
Upon running lspci | grep -E 'VGA|3D'
, One can list all the video devices
available.
01:00.0 VGA compatible controller: NVIDIA Corporation TU117M [GeForce GTX 1650 Mobile / Max-Q] (rev a1)
06:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] (rev c6)
Here it is clear that 2 GPUs are available, the dedicated NVIDIA GTX 1650 Mobile / Max-Q and the integrated AMD Cezanne Radeon Vega Series GPU.
Now, run ls -l /dev/dri/by-path
total 0
lrwxrwxrwx 1 root root 8 Jul 14 15:45 pci-0000:01:00.0-card -> ../card0
lrwxrwxrwx 1 root root 13 Jul 14 15:45 pci-0000:01:00.0-render -> ../renderD128
lrwxrwxrwx 1 root root 8 Jul 14 15:45 pci-0000:06:00.0-card -> ../card1
lrwxrwxrwx 1 root root 13 Jul 14 15:45 pci-0000:06:00.0-render -> ../renderD129
So from the above outputs, we can see that the path for the AMD card is
pci-0000:06:00.0-card
, due to the matching 06:00.0
from the first command.
Do not use the card1
symlink indicated here. It is dynamically assigned at
boot and is subject to frequent change, making it unsuitable as a marker for GPU selection.
Telling Hyprland which GPU to use
After determining which “card” belongs to which GPU, we can now tell
Hyprland which GPUs to use by setting the AQ_DRM_DEVICES
environment variable.
If you would like to use another GPU, or the wrong GPU is picked by default,
set AQ_DRM_DEVICES
to a :
-separated list of card paths, e.g.
env = AQ_DRM_DEVICES,/dev/dri/card0:/dev/dri/card1
Here, we tell Hyprland which GPUs it’s allowed to use, in order of priority.
For example, card0
will be the primary renderer, but if it isn’t available for
whatever reason, then card1
is primary.
Do note that if you have an external monitor connected to, for example card1
,
that card must be included in AQ_DRM_DEVICES
for the monitor to work, though
it doesn’t have to be the primary renderer.
You should now be able to use an integrated GPU for lighter GPU loads, including Hyprland, or default to your dGPU if you prefer.
uwsm users are advised to export the AQ_DRM_DEVICES
variable inside ~/.config/uwsm/env-hyprland
, instead.
This method ensures that the variable is properly exported to the systemd environment without conflicting with other compositors or desktop environments.
export AQ_DRM_DEVICES="/dev/dri/card0:/dev/dri/card1"