setcap on intel_gpu_top

To be able to get GPU info from Intel Arc as a user without sudo I would have to do a setcap as shown here https://github.com/luisbocanegra/plasma-intel-gpu-monitor?tab=readme-ov-file#requirements Sadly with /usr/bin being read only that can't be done. How would this be fixed without something as extreme as a custom image with this done during image build. igt-gpu-tools was added of course to get the binary in the first place.
GitHub
GitHub - luisbocanegra/plasma-intel-gpu-monitor: KDE Plasma Widget ...
KDE Plasma Widget that displays Intel GPU usage including wether or not video acceleration is being used. - luisbocanegra/plasma-intel-gpu-monitor
3 Replies
Azema Viator
Azema ViatorOP2w ago
I see that sunshine has a custom work around to be able to setcap, is that sorta the only way to fix such issues? I have next to no clue what the sunshine fix script is doing but... I think
[Unit]
Description=Set intel_gpu_top perfmon capabilities
ConditionFileIsExecutable=/usr/bin/intel_gpu_top
After=graphical.target
After=local-fs.target

[Service]
Type=oneshot
# Copy if it doesn't exist
ExecStartPre=/usr/bin/bash -c "[ -x /usr/local/bin/.intel_gpu_top ] || /usr/bin/cp /usr/bin/intel_gpu_top /usr/local/bin/.intel_gpu_top"
# This is faster than using .mount unit. Also allows for the previous line/cleanup
ExecStartPre=/usr/bin/bash -c "/usr/bin/mount --bind /usr/local/bin/.intel_gpu_top /usr/bin/intel_gpu_top"
# Fix caps
ExecStart=/usr/bin/bash -c "/usr/sbin/setcap 'cap_perfmon=+ep' $(/usr/bin/readlink -f $(/usr/bin/which intel_gpu_top))"
# Clean-up after ourselves
ExecStop=/usr/bin/umount /usr/bin/intel_gpu_top
ExecStop=/usr/bin/rm /usr/local/bin/.intel_gpu_top
RemainAfterExit=yes


[Install]
WantedBy=multi-user.target
[Unit]
Description=Set intel_gpu_top perfmon capabilities
ConditionFileIsExecutable=/usr/bin/intel_gpu_top
After=graphical.target
After=local-fs.target

[Service]
Type=oneshot
# Copy if it doesn't exist
ExecStartPre=/usr/bin/bash -c "[ -x /usr/local/bin/.intel_gpu_top ] || /usr/bin/cp /usr/bin/intel_gpu_top /usr/local/bin/.intel_gpu_top"
# This is faster than using .mount unit. Also allows for the previous line/cleanup
ExecStartPre=/usr/bin/bash -c "/usr/bin/mount --bind /usr/local/bin/.intel_gpu_top /usr/bin/intel_gpu_top"
# Fix caps
ExecStart=/usr/bin/bash -c "/usr/sbin/setcap 'cap_perfmon=+ep' $(/usr/bin/readlink -f $(/usr/bin/which intel_gpu_top))"
# Clean-up after ourselves
ExecStop=/usr/bin/umount /usr/bin/intel_gpu_top
ExecStop=/usr/bin/rm /usr/local/bin/.intel_gpu_top
RemainAfterExit=yes


[Install]
WantedBy=multi-user.target
Is ok... sudo systemctl enable --now setcap_intel_gpu_top.service seems to have ran the service and I can run intel_gpu_top as a normal user now. I have not checked to see if this works on reboot. I would love if someone that understands the sunshine workaround could confirm I have not done something stupid. Also would getting something to support this as a ujust be open?
HikariKnight
HikariKnight2w ago
it copies the binary to /usr/local/bin and setcaps on that and bind mounts it back to /usr/bin/binaryname
Azema Viator
Azema ViatorOP2w ago
I hope that Intel just finishes the drivers and makes GPU reporting exposed normally and not need this tool anymore
Want results from more Discord servers?
Add your server