# How to run gui apps? DRI/DRM with kmscube "failed to set mode: Permission denied"

**URL:** <https://forums.balena.io/t/how-to-run-gui-apps-dri-drm-with-kmscube-failed-to-set-mode-permission-denied/372285>\
**Category:** Product support\
**Created:** [October 15, 2024, 8:56am UTC](https://forums.balena.io/t/how-to-run-gui-apps-dri-drm-with-kmscube-failed-to-set-mode-permission-denied/372285 "2024-10-15T08:56:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dotdev2](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@dotdev2](https://forums.balena.io/u/dotdev2)\
**Post date:** [October 15, 2024, 8:56am UTC](https://forums.balena.io/t/how-to-run-gui-apps-dri-drm-with-kmscube-failed-to-set-mode-permission-denied/372285/1 "2024-10-15T08:56:40Z")

</div>

Hi,

I cannot get my application to display anything, so i am trying to get some output on the device display.

kmscube errors out with

```auto
[Logs] [2024-10-15T08:52:36.914Z] [kmscube] failed to set mode: Permission denied

```

Dockerfile

```auto
FROM balenalib/genericx86-64-ext-debian:latest

RUN apt-get update && apt-get install -y \
    kmscube \
    libdrm2 \
    libdrm-tests \
    libgbm1 \
    libegl1-mesa \
    libgles2-mesa \
    libgl1-mesa-dri \
    libinput10 \
    udev \
    --no-install-recommends

RUN apt-get install -y \
    x11-utils \
    mesa-utils \
    && apt-get clean

WORKDIR /root

CMD ["kmscube"]

```

Docker compose:

```auto
version: "2"
services:
  kmscube:
    build: .
    restart: always
    privileged: true
    environment:
      UDEV: 1
    devices:
      - "/dev/dri:/dev/dri"
      - "/dev/input:/dev/input"

```

Debugging output from host os:

```auto
root@d94785e:~# udevadm info /dev/dri/card0
P: /devices/pci0000:00/0000:00:02.0/drm/card0
N: dri/card0
L: 0
S: dri/by-path/pci-0000:00:02.0-card
E: DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0
E: DEVNAME=/dev/dri/card0
E: DEVTYPE=drm_minor
E: MAJOR=226
E: MINOR=0
E: SUBSYSTEM=drm
E: USEC_INITIALIZED=5212994
E: ID_PATH=pci-0000:00:02.0
E: ID_PATH_TAG=pci-0000_00_02_0
E: ID_FOR_SEAT=drm-pci-0000_00_02_0
E: DEVLINKS=/dev/dri/by-path/pci-0000:00:02.0-card
E: TAGS=:seat:master-of-seat:uaccess:
E: CURRENT_TAGS=:seat:master-of-seat:uaccess:

root@d94785e:~# lsmod | grep i915
i915 3465216 4
drm_buddy 20480 1 i915
ttm 90112 1 i915
drm_display_helper 200704 1 i915
cec 61440 2 drm_display_helper,i915
drm_kms_helper 225280 2 drm_display_helper,i915
i2c_algo_bit 12288 2 igb,i915
video 69632 1 i915
drm 745472 7 drm_kms_helper,drm_display_helper,drm_buddy,i915,ttm

root@d94785e:~# dmesg | grep -i drm
[1.992384] ACPI: bus type drm_connector registered
[3.911626] i915 0000:00:02.0: [drm] Using Transparent Hugepages
[3.960301] i915 0000:00:02.0: [drm] Finished loading DMC firmware i915/icl_dmc_ver1_09.bin (v1.9)
[4.021750] [drm] Initialized i915 1.6.0 20201103 for 0000:00:02.0 on minor 0
[4.026463] fbcon: i915drmfb (fb0) is primary device
[5.200135] i915 0000:00:02.0: [drm] fb0: i915drmfb frame buffer device

root@d94785e:~# ls -al /dev/dri
total 0
drwxr-xr-x 3 root root 100 Oct 15 08:05 .
drwxr-xr-x 19 root root 4540 Oct 15 08:20 ..
drwxr-xr-x 2 root root 80 Oct 15 08:20 by-path
crw-rw---- 1 root video 226, 0 Oct 15 08:20 card0
crw-rw-rw- 1 root render 226, 128 Oct 15 08:20 renderD128

```

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [October 15, 2024, 10:54am UTC](https://forums.balena.io/t/how-to-run-gui-apps-dri-drm-with-kmscube-failed-to-set-mode-permission-denied/372285/2 "2024-10-15T10:54:54Z")

</div>

Hello @dotdev2

Could you please share more details of what hardware are you using here? What OS version?

Thanks!

---

<div class="post-metadata">

**Author:** ![dotdev2](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@dotdev2](https://forums.balena.io/u/dotdev2)\
**Post date:** [October 15, 2024, 11:41am UTC](https://forums.balena.io/t/how-to-run-gui-apps-dri-drm-with-kmscube-failed-to-set-mode-permission-denied/372285/3 "2024-10-15T11:41:14Z")

</div>

Hi @mpous ,

All in one “terminal device” (integrated screen), Intel Celeron J6412, industrial motherboard, 15.6" full hd touch display.

BalenaOS 6.0.24+rev1

Best,  
F

---

<div class="post-metadata">

**Author:** ![joshbwlng](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/joshbwlng/32/10307_2.png) [@joshbwlng](https://forums.balena.io/u/joshbwlng)\
**Post date:** [October 16, 2024, 1:33am UTC](https://forums.balena.io/t/how-to-run-gui-apps-dri-drm-with-kmscube-failed-to-set-mode-permission-denied/372285/4 "2024-10-16T01:33:02Z")

</div>

Hi @dotdev2 ,

Can you share what exactly the service is attempting to run? I see the Dockerfile installs some necessary libraries etc, but is there anything else other than kmscube itself that is being executed when the service starts? I ask because I found another using running into the same error (albeit not on a balena device), and their issue was caused by a different GUI already running: [Error message when trying to run kmscube - #3 by eran - DragonBoard410c - 96Boards Forum](https://discuss.96boards.org/t/error-message-when-trying-to-run-kmscube/5021/3)

---

<div class="post-metadata">

**Author:** ![dotdev2](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@dotdev2](https://forums.balena.io/u/dotdev2)\
**Post date:** [October 16, 2024, 9:22am UTC](https://forums.balena.io/t/how-to-run-gui-apps-dri-drm-with-kmscube-failed-to-set-mode-permission-denied/372285/5 "2024-10-16T09:22:17Z")

</div>

Hi @joshbwlng,

No other services. I am only running the kmscube, shown in the Dockerfile. There are no other containers on the device.

```auto
root@d94785e:~# balena-engine ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
27fe2295e6e1 fbf2f583c34a "/usr/bin/entry.sh k…" 58 seconds ago Restarting (243) 23 seconds ago kmscube_1_1_10ca12e1ea5e
29c63feae328 registry2.balena-cloud.com/v2/139c93a57103e8c47c803435a0e94793 "/usr/src/app/entry.…" 25 hours ago Up 7 minutes (healthy) balena_supervisor

```

I am using balenalib/genericx86-64-ext-debian:latest. If there is a better choice to run DRI/DRM gui applications such as kmscube please let me know.

The SDDM issue you referenced does not seem to be the issue, the image seems to be barebones.

---

<div class="post-metadata">

**Author:** ![dotdev2](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@dotdev2](https://forums.balena.io/u/dotdev2)\
**Post date:** [October 16, 2024, 10:15am UTC](https://forums.balena.io/t/how-to-run-gui-apps-dri-drm-with-kmscube-failed-to-set-mode-permission-denied/372285/6 "2024-10-16T10:15:01Z")

</div>

Hi @joshbwlng,

Found plymouthd with an open drm device file descriptor running on the host.

```auto
root@d94785e:~# lsof /dev/dri/*
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
plymouthd 1014 root 9u CHR 226,0 0t0 737 /dev/dri/card0

```

Stopping all plymouth systemd units fixes the issue and kmscube runs perfectly.

```auto
systemctl stop plymouth*

```

How can i ensure plymouth is stops as the container starts?

I tried using dbus:

```auto
CMD \
    dbus-send --system --print-reply --dest=org.freedesktop.Plymouth /org/freedesktop/Plymouth org.freedesktop.Plymouth.Quit && \
    sleep 2 && \
    kmscube

```

```auto
version: "2"
services:
  kmscube:
    build: .
    restart: always
    privileged: true
    environment:
      UDEV: 1
      DBUS_SYSTEM_BUS_ADDRESS: unix:path=/host/run/dbus/system_bus_socket
    devices:
      - "/dev/dri:/dev/dri"
      - "/dev/input:/dev/input"
      - "/run/dbus/system_bus_socket:/run/dbus/system_bus_socket"
    labels:
      io.balena.features.dbus: '1'

```

But it does not seem to work.

```auto
Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Plymouth was not provided by any .service files

```

Seems hacky anyway. What’s the correct way to ensure that plymouth is quit as the application containers are started? This problem repeats on every reboot.

Thanks!
