2024-02-20 22:16:07 +02:00
---
2025-08-28 11:20:34 +02:00
weight: 19
2024-02-20 22:16:07 +02:00
title: Multi-GPU
---
2023-07-21 10:19:03 +00:00
2024-02-20 22:16:07 +02:00
## General
2023-07-21 10:19:03 +00:00
2024-04-21 10:35:48 -04:00
If your host machine uses multiple GPUs, you may want to use one GPU
2023-07-21 10:19:03 +00:00
for rendering all the elements for Hyprland including windows, animations, and
another for hardware acceleration for certain applications, etc.
2024-02-20 22:16:07 +02:00
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.
2023-07-21 10:19:03 +00:00
2024-02-20 22:16:07 +02:00
## Detecting GPUs
2023-07-21 10:19:03 +00:00
For this case, the writer is taking the example of their laptop.
2025-04-29 13:39:49 +05:30
Upon running `lspci -d ::03xx` , one can list all the PCI display controllers
2023-07-21 10:19:03 +00:00
available.
2024-11-06 20:34:37 +02:00
```plain
2023-07-21 10:19:03 +00:00
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)
```
2024-02-20 22:16:07 +02:00
2023-07-21 10:19:03 +00:00
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`
2024-11-06 20:34:37 +02:00
```plain
2023-07-21 10:19:03 +00:00
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
```
2024-03-25 20:30:53 +00:00
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.
2023-07-21 10:19:03 +00:00
2024-02-20 22:16:07 +02:00
## Telling Hyprland which GPU to use
2023-07-21 10:19:03 +00:00
2025-02-05 15:50:57 -06:00
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.
2023-07-21 10:19:03 +00:00
2025-10-29 20:52:11 +01:00
> [!NOTE]
> It is generally a good idea for laptops to use the integrated GPU as the primary
> renderer as this preserves battery life and is practically indistinguishable
> from using the dedicated GPU on modern systems in most cases. Hyprland can be
> run on integrated GPUs just fine. The same principle applies for desktop setups
> with lower and higher power rating GPUs respectively.
2023-07-21 10:19:03 +00:00
2025-02-05 15:50:57 -06:00
If you would like to use another GPU, or the wrong GPU is picked by default,
2024-07-21 19:51:02 +02:00
set `AQ_DRM_DEVICES` to a `:` -separated list of card paths, e.g.
2024-03-25 20:30:53 +00:00
2024-11-06 20:34:37 +02:00
```plain
2024-07-21 19:51:02 +02:00
env = AQ_DRM_DEVICES,/dev/dri/card0:/dev/dri/card1
2024-03-25 20:30:53 +00:00
```
2025-02-05 15:50:57 -06:00
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.
2023-07-21 10:19:03 +00:00
2024-03-25 20:30:53 +00:00
You should now be able to use an integrated GPU for lighter GPU loads,
including Hyprland, or default to your dGPU if you prefer.
2024-11-16 23:58:14 +05:00
2025-10-29 20:52:11 +01:00
> [!NOTE]
> [uwsm](../../Useful-Utilities/Systemd-start) 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.
>
> ```plain
> export AQ_DRM_DEVICES="/dev/dri/card0:/dev/dri/card1"
> ```
2025-07-27 05:50:01 -06:00
## Creating consistent device paths for specific cards
As mentioned above, it's not recommended to use the `/dev/dri/card*` device paths since they
periodically change which device they are symlinked to. Furthermore, the colons in the actual card
device paths are not usable in the `AQ_DRM_DEVICES` environment variable since colons `:` are used
as a separator for multiple paths.
It's possible to use udev rules to create reliable symlinks to particular device cards. For example,
to create a symlink to an AMD card at the path `/dev/dri/amd-igpu` , we can create a udev rule at
`/etc/udev/rules.d/amd-igpu-dev-path.rules` programmatically like so:
```sh
SYMLINK_NAME="amd-igpu"
RULE_PATH="/etc/udev/rules.d/amd-igpu-dev-path.rules"
AMD_IGPU_ID=$(lspci -d ::03xx | grep 'AMD' | cut -f1 -d' ')
UDEV_RULE="$(cat < < EOF
KERNEL=="card*", \
KERNELS=="0000:$AMD_IGPU_ID", \
SUBSYSTEM=="drm", \
SUBSYSTEMS=="pci", \
SYMLINK+="dri/$SYMLINK_NAME"
EOF
)"
echo "$UDEV_RULE" | sudo tee "$RULE_PATH"
```
Then reloading the udev rules with:
```sh
sudo udevadm control --reload
sudo udevadm trigger
```
There should now be a symlink at `/dev/dri/amd-igpu` that points to your respective card file:
```console
$ ls -l /dev/dri/amd-igpu
lrwxrwxrwx 1 root root 5 /dev/dri/amd-igpu -> card1
```
This symlink will automatically update to point to correct card file if it ever changes.
Now it is possible to use the new symlink in the `AQ_DRM_DEVICES` environment variable:
```plain
env = AQ_DRM_DEVICES, /dev/dri/amd-igpu
```