2024-02-20 21:16:07 +01:00
|
|
|
---
|
|
|
|
weight: 16
|
|
|
|
title: Multi-GPU
|
|
|
|
---
|
2023-07-21 12:19:03 +02:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
## General
|
2023-07-21 12:19:03 +02:00
|
|
|
|
2024-04-21 16:35:48 +02:00
|
|
|
If your host machine uses multiple GPUs, you may want to use one GPU
|
2023-07-21 12:19:03 +02:00
|
|
|
for rendering all the elements for Hyprland including windows, animations, and
|
|
|
|
another for hardware acceleration for certain applications, etc.
|
|
|
|
|
2024-02-20 21:16:07 +01: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 12:19:03 +02:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
## Detecting GPUs
|
2023-07-21 12:19:03 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
```
|
2024-02-20 21:16:07 +01:00
|
|
|
|
2023-07-21 12:19:03 +02: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`
|
|
|
|
|
|
|
|
```
|
|
|
|
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 21:30:53 +01: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 12:19:03 +02:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
## Telling Hyprland which GPU to use
|
2023-07-21 12:19:03 +02:00
|
|
|
|
|
|
|
After determining which "card" belongs to which GPU, we now have to tell
|
|
|
|
Hyprland the GPU we want to use primarily.
|
2024-03-25 21:30:53 +01:00
|
|
|
This is done by setting the `WLR_DRM_DEVICES` environment variable.
|
2023-07-21 12:19:03 +02:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
{{< callout type=info >}}
|
2023-07-21 12:19:03 +02:00
|
|
|
|
|
|
|
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
|
2024-04-21 16:35:48 +02:00
|
|
|
with lower and higher power rating GPUs respectively.
|
2023-07-21 12:19:03 +02:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
{{< /callout >}}
|
2023-07-21 12:19:03 +02:00
|
|
|
|
2024-03-25 21:30:53 +01:00
|
|
|
If you wish to use the integrated GPU to run Hyprland, no further action is
|
|
|
|
required. wlroots will set `WLR_DRM_DEVICES` to the integrated GPU by default.
|
2023-07-21 12:19:03 +02:00
|
|
|
|
2024-03-25 21:30:53 +01:00
|
|
|
If instead you would like to use another GPU, you must first create a symlink to
|
|
|
|
the card from the previous section.
|
|
|
|
|
2024-04-17 08:13:37 +02:00
|
|
|
It is not possible to use `~/.config/hypr/card` as wlroots will not expand it correctly.
|
|
|
|
You must include full path e.g `$HOME/.config/hypr/card`
|
2024-03-25 21:30:53 +01:00
|
|
|
```
|
2024-04-17 08:13:37 +02:00
|
|
|
ln -sf /dev/dri/by-path/pci-0000:06:00.0-card $HOME/.config/hypr/card
|
2024-03-25 21:30:53 +01:00
|
|
|
```
|
|
|
|
|
2024-04-17 08:13:37 +02:00
|
|
|
It is not possible to directly use the `/dev/dri/by-path/pci-0000:06:00.0-card` path,
|
2024-03-25 21:30:53 +01:00
|
|
|
as wlroots interprets the colon symbols in the path as separators. Escaping
|
|
|
|
characters will not rectify this.
|
|
|
|
|
|
|
|
Afterwards, you must set the `WLR_DRM_DEVICES` environment variable in
|
|
|
|
hyprland.conf to this linked card.
|
2023-07-21 12:19:03 +02:00
|
|
|
|
2024-04-17 08:13:37 +02:00
|
|
|
|
2023-07-21 12:19:03 +02:00
|
|
|
```ini
|
2024-04-17 08:13:37 +02:00
|
|
|
env = WLR_DRM_DEVICES,$HOME/.config/hypr/card
|
2023-07-21 12:19:03 +02:00
|
|
|
```
|
|
|
|
|
2024-03-25 21:30:53 +01:00
|
|
|
If you want to set a sequence of fallback cards, symlink another card and set
|
|
|
|
the var as a colon separated list in order of priority.
|
2023-07-21 12:19:03 +02:00
|
|
|
|
|
|
|
```ini
|
2024-04-17 08:13:37 +02:00
|
|
|
env = WLR_DRM_DEVICES,$HOME/.config/hypr/card:$HOME/.config/hypr/otherCard
|
2023-07-21 12:19:03 +02:00
|
|
|
```
|
|
|
|
|
2024-03-25 21:30:53 +01:00
|
|
|
Here, we tell Hyprland to set priorities. If `card` isn't available for
|
|
|
|
whatever reason, use `otherCard`. So if the AMD GPU isn't available, use NVIDIA.
|
2023-07-21 12:19:03 +02:00
|
|
|
|
2024-03-25 21:30:53 +01: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.
|