Skip to content

Instantly share code, notes, and snippets.

@sergioperez
Last active April 1, 2024 14:27
Show Gist options
  • Save sergioperez/5f312f345d6281705d5689a348373f7e to your computer and use it in GitHub Desktop.
Save sergioperez/5f312f345d6281705d5689a348373f7e to your computer and use it in GitHub Desktop.
ubuntu2110-amd-sunshine

Draft - AWS + AMDGPU + Wayland headless + Sunshine

Install amdgpu drivers

apt update
apt install linux-modules-extra-$(uname -r) linux-firmware libgl1-mesa-dri libglx-mesa0 mesa-vulkan-drivers xserver-xorg-video-all
apt install -y mesa-utils mesa-utils-extra xserver-xorg-video-amdgpu

Build dependencies

apt install -y cmake gcc-10 g++-10 libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libevdev-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libdrm-dev libcap-dev libwayland-dev
reboot

Check if gpu is visible

dmesg | grep amdgpu
ls /dev/dri*

Build Sunshine

# My fork has a fix to accept the virtual connectors. I guess this will be merged soon to the main project :)
git clone https://github.com/sergioperez/sunshine.git -b add-virtual-connectors --recurse-submodules
cd sunshine && mkdir build && cd build
cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 ..
make -j4
setcap cap_sys_admin+p sunshine

Fix permissions

sudo usermod -aG input ubuntu
sudo usermod -aG video ubuntu
sudo usermod -aG render ubuntu
echo 'KERNEL=="uinput", GROUP="input", MODE="0660"' > /etc/udev/rules.d/85-sunshine-input.rules
echo uinput > /etc/modules-load.d/uinput.conf
systemctl restart udev

Create tmp dir in $HOME

mkdir ~/tmp

Execute sway

export WLR_BACKENDS=headless
export WAYLAND_DISPLAY=wayland-0
export XDG_RUNTIME_DIR=${HOME}/tmp
export XDG_SESSION_TYPE=wayland
dbus-run-session sway

Execute sunshine

export WLR_BACKENDS=headless
export WAYLAND_DISPLAY=wayland-0
export XDG_RUNTIME_DIR=${HOME}/tmp
export XDG_SESSION_TYPE=wayland
sunshine

In order to use KWin instead of sway:

apt install -y kwin-wayland kwin-wayland-backend-virtual
kwin-wayland --virtual
@SchoolGuy
Copy link

I wasn't able to find the MR that you teased. Is this upstream in the meantime? I was wondering if it makes sense to self-host this on my headless setup in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment