-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add full support for AMD NPUs #417
Comments
Hi, thanks for the issue. |
xdna-driver supports drm usage stats (fdinfo). |
I don't think that supports temps, power usage, etc, but that's good to know! Also, unless I'm doing something wrong, it seems like memory and usage isn't reported at all, or at least incorrectly.
use std::{fs::File, io::{BufRead, BufReader}, os::fd::AsRawFd};
fn main() {
println!("Opening /dev/accel/accel0...");
match File::open("/dev/accel/accel0") {
Ok(f) => {
let fd = f.as_raw_fd();
println!("Got fd: {}", fd);
println!("\nTrying to read DRM stats from /proc/self/fdinfo/{}:", fd);
match File::open(format!("/proc/self/fdinfo/{}", fd)) {
Ok(fdinfo) => {
let reader = BufReader::new(fdinfo);
for line in reader.lines().flatten() {
if line.starts_with("drm-") {
println!(" {}", line);
}
}
}
Err(e) => println!("Error opening fdinfo: {}", e),
}
}
Err(e) => println!("Error opening device: {}", e),
}
} |
The result itself is probably correct. |
Do you mind trying out the |
Unfortunately usage doesn't seem to work, but it now shows "0%" instead of N/A npu_resources_test.webm |
Do you mind sending me debug logs (run resources with the environment variable |
Here's the logs with some extraneous stuff (like associated processes/finding apps) removed:
|
In the folder where you've pulled this repo to, there's probably a folder called ".flatpak" or "flatpak_app", within its subfolders should be a binary called "resources-processes" (for me it's ".flatpak/repo/libexec/resources-processes", but I'm using VSCode to build it), can you run this binary with the following arguments |
Interestingly, I get a lot of Also, for me the binary is located in |
Yeah, I've just noticed too that there is a bug where resources-processes doesn't differentiate between NPU usage and GPU usage. |
Do you want me to send all the |
Give me a couple of minutes (hopefully), I'll notify you. :) |
@ThatOneCalculator You can pull and try again :) |
I just opened it as a text file in vscode, and it showed the normal logs after a little bit of unicode |
Can you send me a screenshot or excerpt of one process with gpu_usage_stats or npu_usage_stats not empty, like this?
|
|
Just to make sure, you're still on the |
I am, yeah. Built against this as the latest commit:
|
Ah, so sorry!!! Was running against an outdated build in a different dir!! |
No problem, happens. :) |
There seems to be 537 entries for
|
Also, here's the entry for the process that should be showing npu usage:
|
Alright, I've added some debug and trace print statements into resources-processes. #!/bin/bash
NPU_PID=x # Replace 'x' with the pid of an NPU-intensive process
TARGET_FOLDER="/proc/$NPU_PID/fdinfo"
for file in "$TARGET_FOLDER"/*; do
if [ -f "$file" ]; then
echo ""
echo "=== Content of $file ==="
cat "$file"
fi
done The output should look kinda like this, feel free to omit anything not NPU-related:
After that, while the task is still running, please run
|
Will be able to test tomorrow! |
Have you had the chance to test it yet? :) |
I'd really like to merge this, is there someone who has a new AMD CPU with an NPU who could test this? |
Yes, it's for amdxdna. Can you check using |
Yeah, it turns out that the problem is in the driver, which for some reason isn't loaded: |
@Nikitf777 you still need to load the XDNA driver separately – all 6.14rc1 is enable hardware acceleration for XDNA devices, it doesn't actually provide the interfacing framework. https://aur.archlinux.org/packages/amdxdna-driver-bin |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe.
Right now, there's support for Intel and Rockchip NPUs, but for AMD NPUs there's no graph
Describe the solution you'd like
Support for AMD NPUs and their stats, likely using the AMD XDNA Driver
Current behavior:
The text was updated successfully, but these errors were encountered: