Umio-Yasuno / amdgpu_top

Tool to display AMDGPU usage
MIT License
750 stars 15 forks source link

No such file or directory, then panic/backtrace #11

Closed colemickens closed 1 year ago

colemickens commented 1 year ago
╭ zeph  ~/code/nixcfg 0s
╰─▶ /nix/store/hhclh187i2pkll9i2cqghbbizk7nd06j-amdgpu_top-0.1.7/bin/amdgpu_top
No such file or directory (os error 2)
render_path = "/dev/dri/renderD128"
card_path = "/dev/dri/card0"
thread 'main' panicked at 'explicit panic', src/main.rs:92:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm trying to package this for nixpkgs and use it on my G14 2022 (AMD+AMD), but not having a lot of luck so far.

Any advice? Setting RUST_BACKTRACE to 1 or full didn't really help.

Umio-Yasuno commented 1 year ago

I do not provide nixpkg and I am not familiar with nixpkg. Try a binary built from source or an AppImage binary.

sandbox setting might be affecting it? https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-sandbox

colemickens commented 1 year ago

I am building from source, and the binary builds fine, this is at execution time which does not happen in the sandbox.

Umio-Yasuno commented 1 year ago

Please paste the results of running ls -l /dev/dri.

amdgpu_top requires access to /dev/dri/. Environments with device files located in locations other than /dev/dri are not supported.

colemickens commented 1 year ago
❯ exa -al --tree /dev/dri
drwxr-xr-x        - root  2 May 15:33 /dev/dri
drwxr-xr-x        - root  2 May 15:44 ├── by-path
lrwxrwxrwx@       8 root  2 May 15:44 │  ├── pci-0000:07:00.0-card -> ../card1
lrwxrwxrwx       13 root  2 May 15:44 │  └── pci-0000:07:00.0-render -> ../renderD129
crw-rw----@   226,1 root  2 May 15:44 ├── card1
crw-rw-rw-  226,129 root  2 May 15:44 └── renderD129
colemickens commented 1 year ago

This system has two GPUs, but I usually boot Linux with the dGPU disabled.

This might be why my system (currently) only has dri1.

I can take a peek at the code...

Umio-Yasuno commented 1 year ago

Run amdgpu_top -i 1. The result of amdgpu_top --list is also helpful.

colemickens commented 1 year ago
╭ zeph  ~/code/nixcfg 21.12s
╰─▶ /nix/store/hhclh187i2pkll9i2cqghbbizk7nd06j-amdgpu_top-0.1.7/bin/amdgpu_top -i 1

seems to work, shows the TUI
╭ zeph  ~/code/nixcfg 1.85s
╰─▶ /nix/store/hhclh187i2pkll9i2cqghbbizk7nd06j-amdgpu_top-0.1.7/bin/amdgpu_top --list
#1
Marketing Name = "AMD Radeon Graphics"
pci = 0000:07:00.0
render_path = "/dev/dri/renderD129"
card_path = "/dev/dri/card1"
Umio-Yasuno commented 1 year ago
╭ zeph  ~/code/nixcfg 21.12s
╰─▶ /nix/store/hhclh187i2pkll9i2cqghbbizk7nd06j-amdgpu_top-0.1.7/bin/amdgpu_top -i 1

seems to work, shows the TUI
╭ zeph  ~/code/nixcfg 1.85s
╰─▶ /nix/store/hhclh187i2pkll9i2cqghbbizk7nd06j-amdgpu_top-0.1.7/bin/amdgpu_top --list
#1
Marketing Name = "AMD Radeon Graphics"
pci = 0000:07:00.0
render_path = "/dev/dri/renderD129"
card_path = "/dev/dri/card1"

Ok, close this issue.

colemickens commented 1 year ago

I don't understand. The app tries to load the wrong card? Or maybe you're addressing it and I just don't understand?

Umio-Yasuno commented 1 year ago

I don't understand. The app tries to load the wrong card? Or maybe you're addressing it and I just don't understand?

The first DRM devices will be placed in /dev/dri/renderD128 and /dev/dri/card0 unless intentionally disabled. Therefore, amdgpu_top selects /dev/dri/renderD128 by default. Open "/dev/dri/render{}", 128 + i if an instance (-i) is specified.

colemickens commented 1 year ago

Does it make sense to:

  1. Auto-select the first available instead of assuming index 0?
  2. Support multi-GPU setups through-out the app?

I understand if that's all out of scope. It is very jarring to get a file not found and panic, though.

Umio-Yasuno commented 1 year ago

GUI mode implements GPU selection fallback. This is because in GUI mode, other GPU devices can be started in a new process.

https://github.com/Umio-Yasuno/amdgpu_top/commit/ac94ed0f8ecfa1a45fd20cc2e9dca5ee72bcf840