clbr / radeontop

GNU General Public License v3.0
804 stars 70 forks source link

radeontop - non-root access #61

Closed fermulator closed 3 years ago

fermulator commented 6 years ago

As per #51 , a community contributor (@franglais125) was adding support for GPU monitoring directly in gnome system monitor (awesome!) - nVidia support was added, but AMD not yet;

radeontop was proven capable to query + parse the necessary information there, however, the problem is that it required root privs.

A comment from @clbr in https://github.com/clbr/radeontop/issues/51#issuecomment-322983286, indicates:

Root rights are not required if your kernel is new enough, libdrm is new enough, and your user has access to the DRM node. If you tried to run radeontop without a Radeon card, it would fail to find one in DRM, and assume it needed the root path - even if your system otherwise was set up for non-root access.

More details? I'm on latest Ubuntu 18.04 just recently, and still radeontop isn't ready for non-root usage.

$ radeontop
Cannot access GPU registers, are you root?

(if we run as root of course it works)

$ uname -a
Linux fermmy 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

$ dpkg --list | grep libdrm | awk '{print $1,$2, $3}'
ii libdrm-amdgpu1:amd64 2.4.91-2
ii libdrm-amdgpu1:i386 2.4.91-2
ii libdrm-common 2.4.91-2
ii libdrm-dev:amd64 2.4.91-2
ii libdrm-intel1:amd64 2.4.91-2
ii libdrm-intel1:i386 2.4.91-2
rc libdrm-nouveau1a:amd64 2.4.52-1~precise2
rc libdrm-nouveau1a:i386 2.4.52-1~precise2
ii libdrm-nouveau2:amd64 2.4.91-2
ii libdrm-nouveau2:i386 2.4.91-2
ii libdrm-radeon1:amd64 2.4.91-2
ii libdrm-radeon1:i386 2.4.91-2
ii libdrm2:amd64 2.4.91-2
ii libdrm2:i386 2.4.91-2

How to access "DRM node"?

clbr commented 6 years ago

The DRM node is /dev/dri/card0 on systems with just one GPU. Otherwise the number might be something else.

I don't have the required kernel/libdrm versions at hand, but Ubuntu 18.04 is certainly new enough. I believe the issue for you is that your card is new; only the "radeon" cards currently support non-root querying, your RX card is an "amdgpu" card. That support is in a pull request with some issues, nobody is working on it, and I have no such cards either.

Fatmice commented 5 years ago

Hello, I'm using Fedora 29, my graphic card is a Sapphire Radeon RX Vega 64

unam -a
Linux yellowtrain 5.0.4-200.fc29.x86_64 #1 SMP Mon Mar 25 02:27:33 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

sudo dnf list --installed *drm*
libdrm.x86_64                                                          2.4.97-1.fc29

ls -la /dev/dri
total 0
drwxr-xr-x.  3 root root        100 Mar 30 02:02 .
drwxr-xr-x. 21 root root       4840 Mar 30 23:13 ..
drwxr-xr-x.  2 root root         80 Mar 30 02:02 by-path
crw-rw----+  1 root video  226,   0 Apr  2 20:39 card0
crw-rw-rw-.  1 root render 226, 128 Mar 30 02:02 renderD128

lspci -vnn
45:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Vega 10 XL/XT [Radeon RX Vega 56/64] [1002:687f] (rev c1) (prog-if 00 [VGA controller])
    Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] RX Vega64 [1002:0b36]
    Flags: bus master, fast devsel, latency 0, IRQ 99, NUMA node 1
    Memory at 80000000 (64-bit, prefetchable) [size=256M]
    Memory at 90000000 (64-bit, prefetchable) [size=2M]
    I/O ports at 3000 [size=256]
    Memory at 9f200000 (32-bit, non-prefetchable) [size=512K]
    Expansion ROM at 000c0000 [disabled] [size=128K]
    Capabilities: <access denied>
    Kernel driver in use: amdgpu
    Kernel modules: amdgpu
45:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Vega 10 HDMI Audio [Radeon Vega 56/64] [1002:aaf8]
    Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] Vega 10 HDMI Audio [Radeon Vega 56/64] [1002:aaf8]
    Flags: bus master, fast devsel, latency 0, IRQ 155, NUMA node 1
    Memory at 9f2a0000 (32-bit, non-prefetchable) [size=16K]
    Capabilities: <access denied>
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel

I also get the same message when running the command without sudo

$ radeontop
Cannot access GPU registers, are you root?

How can I run the command without sudo? Do I need to configure selinux to allow radeontop to read /dev/drm and /dev/mem? Something like this? or This?

clbr commented 5 years ago

Your card is also an amdgpu card, and that situation hasn't changed unfortunately. I suppose giving your user read access to /dev/mem would work, but that'd be horribly insecure.

Fatmice commented 5 years ago

Thanks for answering. Running with sudo gives this

Failed to open DRM node, no VRAM support.
Collecting data, please wait....

before it launches something that looks like an ncurses GUI https://streamable.com/xp92n So at least it works with sudo albeit with some worrying messages.

clbr commented 5 years ago

Non-root access for amdgpu might work in current git, please try.

mark9064 commented 5 years ago

With the amdgpu-pro stack, non-root seems to be working (built v1.2-8-g09d8c0b)

MauroMombelli commented 4 years ago

amdgpu 19.0.1-1 non-root access does not seems to work, im part of the group video and crw-rw----+ 1 root video 226, 0 Sep 23 00:09 card0

Bengt commented 4 years ago

For my RX Vega 64s, non-root access does indeed work using amdgpu 19.0.1-1 under Ubuntu 18.04.

$ groups
docker adm tty uucp dialout cdrom sudo dip video plugdev lpadmin sambashare

I upgraded my kernel using ukuu, though:

$ uname -a
Linux bengt-desktop 5.2.14-050214-generic #201909101030 SMP Tue Sep 10 10:33:06 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Bengt commented 4 years ago

The README currently states:

Requires access to /dev/dri/cardN files or /dev/mem (root privileges).

Should we add a link from the README to this issue for more details to users to whom running as root is an inacceptable limitation?

clbr commented 4 years ago

No, this issue will be closed in the future. Non-root support for amdgpu is now in git.

luyatshimbalanga commented 4 years ago

I confirm the support of non-root access using the 20191001 git snapshot.

Hello, I'm using Fedora 29, my graphic card is a Sapphire Radeon RX Vega 64

unam -a
Linux yellowtrain 5.0.4-200.fc29.x86_64 #1 SMP Mon Mar 25 02:27:33 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

sudo dnf list --installed *drm*
libdrm.x86_64                                                          2.4.97-1.fc29

ls -la /dev/dri
total 0
drwxr-xr-x.  3 root root        100 Mar 30 02:02 .
drwxr-xr-x. 21 root root       4840 Mar 30 23:13 ..
drwxr-xr-x.  2 root root         80 Mar 30 02:02 by-path
crw-rw----+  1 root video  226,   0 Apr  2 20:39 card0
crw-rw-rw-.  1 root render 226, 128 Mar 30 02:02 renderD128

lspci -vnn
45:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Vega 10 XL/XT [Radeon RX Vega 56/64] [1002:687f] (rev c1) (prog-if 00 [VGA controller])
  Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] RX Vega64 [1002:0b36]
  Flags: bus master, fast devsel, latency 0, IRQ 99, NUMA node 1
  Memory at 80000000 (64-bit, prefetchable) [size=256M]
  Memory at 90000000 (64-bit, prefetchable) [size=2M]
  I/O ports at 3000 [size=256]
  Memory at 9f200000 (32-bit, non-prefetchable) [size=512K]
  Expansion ROM at 000c0000 [disabled] [size=128K]
  Capabilities: <access denied>
  Kernel driver in use: amdgpu
  Kernel modules: amdgpu
45:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Vega 10 HDMI Audio [Radeon Vega 56/64] [1002:aaf8]
  Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] Vega 10 HDMI Audio [Radeon Vega 56/64] [1002:aaf8]
  Flags: bus master, fast devsel, latency 0, IRQ 155, NUMA node 1
  Memory at 9f2a0000 (32-bit, non-prefetchable) [size=16K]
  Capabilities: <access denied>
  Kernel driver in use: snd_hda_intel
  Kernel modules: snd_hda_intel

I also get the same message when running the command without sudo

$ radeontop
Cannot access GPU registers, are you root?

How can I run the command without sudo? Do I need to configure selinux to allow radeontop to read /dev/drm and /dev/mem? Something like this? or This?

rdmello commented 3 years ago

Hi, I just tried building the current git master branch of radeontop on Ubuntu 20.04 to get it to run without root access, and it is now working fine for my GPU (AMD Radeon RX5700 XT) without needing to run sudo. Thanks for adding support for this.