Skip to content
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

Open
1 task done
ThatOneCalculator opened this issue Dec 10, 2024 · 33 comments · May be fixed by #431
Open
1 task done

Add full support for AMD NPUs #417

ThatOneCalculator opened this issue Dec 10, 2024 · 33 comments · May be fixed by #431
Labels
enhancement New feature or request

Comments

@ThatOneCalculator
Copy link

ThatOneCalculator commented Dec 10, 2024

Is there an existing issue for this?

  • I have searched the existing issues

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:

image

@ThatOneCalculator ThatOneCalculator added the enhancement New feature or request label Dec 10, 2024
@ThatOneCalculator ThatOneCalculator changed the title Add support for AMD NPUs Add full support for AMD NPUs Dec 10, 2024
@nokyan
Copy link
Owner

nokyan commented Dec 10, 2024

Hi, thanks for the issue.
If the amdxdna driver exposes utilization information, I'll try to implement support for it. :)

@Umio-Yasuno
Copy link

xdna-driver supports drm usage stats (fdinfo).

amd/xdna-driver#262

@ThatOneCalculator
Copy link
Author

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.

Opening /dev/accel/accel0...
Got fd: 4

Trying to read DRM stats from /proc/self/fdinfo/4:
  drm-driver:    amdxdna_accel_driver
  drm-client-id:    76
  drm-pdev:    0000:c5:00.1
  drm-engine-npu-amdxdna:    0 ns
  drm-total-memory:    0
  drm-shared-memory:    0
  drm-active-memory:    0
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),
    }
}

@Umio-Yasuno
Copy link

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.

Opening /dev/accel/accel0...
Got fd: 4

Trying to read DRM stats from /proc/self/fdinfo/4:
  drm-driver:    amdxdna_accel_driver
  drm-client-id:    76
  drm-pdev:    0000:c5:00.1
  drm-engine-npu-amdxdna:    0 ns
  drm-total-memory:    0
  drm-shared-memory:    0
  drm-active-memory:    0
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),
    }
}

fdinfo is per-process information.
A full scan of /proc can give you a rough idea of ​​overall usage.

The result itself is probably correct.

@nokyan
Copy link
Owner

nokyan commented Dec 14, 2024

Do you mind trying out the amdxdna-support branch?

@ThatOneCalculator
Copy link
Author

Unfortunately usage doesn't seem to work, but it now shows "0%" instead of N/A

npu_resources_test.webm

@nokyan
Copy link
Owner

nokyan commented Dec 14, 2024

Do you mind sending me debug logs (run resources with the environment variable RUST_LOG=resources=debug set)?

@ThatOneCalculator
Copy link
Author

Here's the logs with some extraneous stuff (like associated processes/finding apps) removed:

 DEBUG resources::utils > Running as Flatpak
 INFO  resources::application > Resources (net.nokyan.Resources.Devel)
 INFO  resources::application > Version: 1.7.1-amdxdna-support/d7a7f15
 INFO  resources::application > Datadir: /app/share/resources
 DEBUG resources::application > Operating system: Arch Linux
 DEBUG resources::application > Kernel version: 6.13.0-rc2-1-mainline-um5606-dirty
 INFO  resources::application > You are running a development version of Resources, things may be slow or break!
Fontconfig error: Cannot load config file "/run/host/font-dirs.xml": No such file: /run/host/font-dirs.xml

(resources:2): Gtk-WARNING **: 13:06:10.827: Unable to acquire the address of the accessibility bus: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown. If you are attempting to run GTK without a11y support, GTK_A11Y should be set to 'none'.
 DEBUG resources::utils::gpu  > Searching for GPUs…
 DEBUG resources::utils::pci  > Parsing pci.ids…
 INFO  resources::utils::pci  > Successfully parsed pci.ids within 11.31ms (vendors: 2406, devices: 19158, subdevices: 16665)
 DEBUG resources::utils::gpu::amd > Parsing /run/host/usr/share/libdrm/amdgpu.ids…
 DEBUG resources::utils::gpu::amd > Successfully parsed /run/host/usr/share/libdrm/amdgpu.ids within 792.30µs (573 entries)
 INFO  resources::utils::gpu      > Found GPU "AMD Radeon Graphics (Strix [Radeon 880M / 890M])" (PCI slot: 0000:c4:00.0 · PCI ID: 1002:150e · Category: AMD)
 DEBUG resources::utils::gpu      > 1 GPUs found
 DEBUG resources::utils::app      > Detecting installed apps
 DEBUG resources::utils::app      > Using the following directories for app detection: ["/app/share/applications", "/usr/share/applications", "/usr/share/runtime/share/applications", "/run/host/user-share/applications", "/run/host/usr/share/applications", "/run/host/share/applications", "/app/local/share/applications", "/usr/local/share/applications", "/usr/local/share/runtime/share/applications", "/run/host/usr/local/share/applications", "/run/host/local/share/applications", "/var/lib/flatpak/exports/share/applications", "/home/kainoa/.local/share/flatpak/exports/share/applications", "/var/lib/snapd/desktop/applications", "/home/kainoa/.local/share/applications"]
 DEBUG resources::utils::app      > Using the following locales for app names and descriptions: ["en_US.utf8", "en_US", "en"]
 INFO  resources::utils::app      > Detected 322 apps within 21.71ms
 DEBUG resources::utils::memory   > Memory information obtained using udevadm
 DEBUG resources::utils::npu      > Searching for NPUs…
 INFO  resources::utils::npu      > Found NPU "Strix Neural Processing Unit" (PCI slot: 0000:c5:00.1 · PCI ID: 1022:17f0 · Category: AMD)
 DEBUG resources::utils::npu      > 1 NPUs found
 DEBUG resources::utils::cpu      > CPU temperature sensor located at /sys/class/hwmon/hwmon6/temp1_input (k10temp)
 DEBUG resources::utils::process  > Spawning resources-processes in Flatpak mode (/home/kainoa/Downloads/resources/.flatpak-builder/rofiles/rofiles-78ArUe/files/libexec/resources/resources-processes)
 DEBUG resources::utils::app      > Associating process 3000729 with app "Resources" (ID: "net.nokyan.Resources.Devel") based on process cgroup matching with app ID
 DEBUG resources::utils::app      > Associating process 3000748 with app "Resources" (ID: "net.nokyan.Resources.Devel") based on process cgroup matching with app ID
 DEBUG resources::utils::app      > Associating process 3000749 with app "Resources" (ID: "net.nokyan.Resources.Devel") based on process cgroup matching with app ID
 DEBUG resources::utils::app      > Associating process 3000752 with app "Resources" (ID: "net.nokyan.Resources.Devel") based on process cgroup matching with app ID
 DEBUG resources::utils::app      > Associating process 3000753 with app "Resources" (ID: "net.nokyan.Resources.Devel") based on process cgroup matching with app ID
 DEBUG resources::utils::app      > Associating process 3000802 with app "Resources" (ID: "net.nokyan.Resources.Devel") based on process cgroup matching with app ID
 DEBUG resources::utils::app      > Associating process 3000806 with app "Resources" (ID: "net.nokyan.Resources.Devel") based on match in KNOWN_EXECUTABLE_NAME_EXCEPTIONS
 INFO  resources::ui::window      > A drive has been added (or turned visible): /sys/block/nvme0n1
 INFO  resources::ui::window      > A network interface has been added (or turned visible): /sys/class/net/wlan0
 INFO  resources::ui::window      > A battery has been added: /sys/class/power_supply/BAT0

(resources:2): Gdk-WARNING **: 13:06:11.847: vkAcquireNextImageKHR(): A swapchain no longer matches the surface properties exactly, but can still be used to present to the surface successfully. (VK_SUBOPTIMAL_KHR) (1000001003)

@nokyan
Copy link
Owner

nokyan commented Dec 14, 2024

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 resources-processes -o -r and send the output (preferably excerpts with the field "npu_usage_stats" not empty, the output will be very large)? Double-check that there's no personally identifiable data like names in there.

@ThatOneCalculator
Copy link
Author

ThatOneCalculator commented Dec 14, 2024

Interestingly, I get a lot of gpu_usage_stats outputs but no npu_usage_stats outputs, even when running the resources-processes command while running the XDNA NPU example.

Also, for me the binary is located in .flatpak/repo/files/libexec/resources/resources-processes

@nokyan
Copy link
Owner

nokyan commented Dec 14, 2024

Interestingly, I get a lot of gpu_usage_stats outputs but no npu_usage_stats outputs, even when running the resources-processes command while running the XDNA NPU example

Yeah, I've just noticed too that there is a bug where resources-processes doesn't differentiate between NPU usage and GPU usage.

@ThatOneCalculator
Copy link
Author

Do you want me to send all the gpu_usage_stats or just wait?

@nokyan
Copy link
Owner

nokyan commented Dec 14, 2024

Do you want me to send all the gpu_usage_stats or just wait?

Give me a couple of minutes (hopefully), I'll notify you. :)

@nokyan
Copy link
Owner

nokyan commented Dec 14, 2024

@ThatOneCalculator You can pull and try again :)

@ThatOneCalculator
Copy link
Author

I can't seem to find where it actually says "npu_usage" 🤔

image

@nokyan
Copy link
Owner

nokyan commented Dec 14, 2024

I can't seem to find where it actually says "npu_usage" 🤔

That's quite odd, I don't have an NPU though lots of empty npu_usage_stats fields
image
Though the "binary file matches" stuff happens because the first four bytes is the length of the following content in binary, Resources needs that. You just removed those first four bytes in vSCode I assume?

@ThatOneCalculator
Copy link
Author

You just removed those first four bytes in vSCode I assume?

I just opened it as a text file in vscode, and it showed the normal logs after a little bit of unicode

@nokyan
Copy link
Owner

nokyan commented Dec 14, 2024

You just removed those first four bytes in vSCode I assume?

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?

    (
        pid: 149834,
        parent_pid: 149833,
        user: "nokyan",
        comm: "loupe",
        commandline: "/app/bin/loupe\0--gapplication-service\0",
        user_cpu_time: 35,
        system_cpu_time: 16,
        niceness: (0),
        affinity: [
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
        ],
        memory_usage: 25403392,
        swap_usage: 0,
        starttime: 1687313,
        cgroup: Some("org.gnome.Loupe"),
        containerization: Flatpak,
        read_bytes: Some(102400),
        write_bytes: Some(663552),
        timestamp: 1734211947096,
        gpu_usage_stats: {
            (
                domain: 0,
                bus: 45,
                number: 0,
                function: 0,
            ): (
                gfx: 66823570,
                mem: 35753984,
                enc: 0,
                dec: 0,
                nvidia: false,
            ),
        },
        npu_usage_stats: {},
    )

@ThatOneCalculator
Copy link
Author

ThatOneCalculator commented Dec 14, 2024

    (
        pid: 3033353,
        parent_pid: 2193,
        user: "kainoa",
        comm: "firefox",
        commandline: "/usr/lib/firefox/firefox\0",
        user_cpu_time: 7622,
        system_cpu_time: 1780,
        niceness: (0),
        affinity: [
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
        ],
        memory_usage: 251604992,
        swap_usage: 0,
        starttime: 10243378,
        cgroup: Some("firefox"),
        containerization: None,
        read_bytes: Some(39702528),
        write_bytes: Some(278487040),
        timestamp: 1734212614309,
        gpu_usage_stats: {
            (
                domain: 0,
                bus: 196,
                number: 0,
                function: 0,
            ): (
                gfx: 6470733323,
                mem: 254169088,
                enc: 0,
                dec: 0,
                nvidia: false,
            ),
        },
    ),

@nokyan
Copy link
Owner

nokyan commented Dec 14, 2024

Just to make sure, you're still on the amdxdna-support branch, right? Because there should be an npu_usage_stats field, no matter if detection actually works.

@ThatOneCalculator
Copy link
Author

I am, yeah. Built against this as the latest commit:

commit 40fe09b2c60d38098d635c7a884d09a18f77d08c (HEAD -> amdxdna-support, origin/amdxdna-support)
Author: nokyan <[email protected]>
Date:   Sat Dec 14 22:34:56 2024 +0100

    Use driver name to differentiate between NPU and GPU usage stats

@ThatOneCalculator
Copy link
Author

Ah, so sorry!!! Was running against an outdated build in a different dir!!

@nokyan
Copy link
Owner

nokyan commented Dec 14, 2024

Ah, so sorry!!! Was running against an outdated build in a different dir!!

No problem, happens. :)

@ThatOneCalculator
Copy link
Author

ThatOneCalculator commented Dec 14, 2024

There seems to be 537 entries for npu_usage_stats and also 537 for npu_usage_stats: {} when running the XDNA example. Here's Firefox again:

    (
        pid: 3434528,
        parent_pid: 2193,
        user: "kainoa",
        comm: "firefox",
        commandline: "/usr/lib/firefox/firefox\0",
        user_cpu_time: 11121,
        system_cpu_time: 2407,
        niceness: (0),
        affinity: [
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
        ],
        memory_usage: 271912960,
        swap_usage: 0,
        starttime: 10453040,
        cgroup: Some("firefox"),
        containerization: None,
        read_bytes: Some(110297088),
        write_bytes: Some(481304576),
        timestamp: 1734214470757,
        gpu_usage_stats: {
            (
                domain: 0,
                bus: 196,
                number: 0,
                function: 0,
            ): (
                gfx: 7280132669,
                mem: 306966528,
                enc: 0,
                dec: 0,
                nvidia: false,
            ),
        },
        npu_usage_stats: {},
    ),

@ThatOneCalculator
Copy link
Author

Also, here's the entry for the process that should be showing npu usage:

    (
        pid: 3866408,
        parent_pid: 3859805,
        user: "kainoa",
        comm: "example_noop_te",
        commandline: "./example_build/example_noop_test\0../tools/bins/1502_00/validate.xclbin\0",
        user_cpu_time: 1,
        system_cpu_time: 6,
        niceness: (0),
        affinity: [
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
        ],
        memory_usage: 983040,
        swap_usage: 0,
        starttime: 10606413,
        cgroup: Some("ghostty"),
        containerization: None,
        read_bytes: Some(90112),
        write_bytes: Some(0),
        timestamp: 1734214836410,
        gpu_usage_stats: {},
        npu_usage_stats: {},
    ),

@nokyan
Copy link
Owner

nokyan commented Dec 15, 2024

Alright, I've added some debug and trace print statements into resources-processes.
Can you please start an NPU-intensive process, note its PID and run this script and send me its output:

#!/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:

=== Content of /proc/332010/fdinfo/0 ===
pos:	0
flags:	0100000
mnt_id:	36
ino:	4

=== Content of /proc/332010/fdinfo/1 ===
pos:	0
flags:	02
mnt_id:	10
ino:	1581151
scm_fds: 0

=== Content of /proc/332010/fdinfo/10 ===
pos:	0
flags:	0100000
mnt_id:	1675
ino:	4

=== Content of /proc/332010/fdinfo/11 ===
pos:	0
flags:	02000000
mnt_id:	16
ino:	1586445

=== Content of /proc/332010/fdinfo/12 ===
pos:	0
flags:	02000001
mnt_id:	16
ino:	1586445

=== Content of /proc/332010/fdinfo/13 ===
pos:	0
flags:	02000002
mnt_id:	17
ino:	2083
tfd:       20 events:       19 data:               14  pos:0 ino:19b201 sdev:9
tfd:        4 events:       19 data:                4  pos:0 ino:200cc3 sdev:9
tfd:        6 events:       19 data:                6  pos:0 ino:181a91 sdev:9
tfd:       26 events:       19 data:               1a  pos:0 ino:19ceb4 sdev:9
tfd:       16 events:       19 data:               10  pos:0 ino:1830bc sdev:f
tfd:        3 events:       19 data:                3  pos:0 ino:17ebb2 sdev:f

=== Content of /proc/332010/fdinfo/14 ===
pos:	0
flags:	02004000
mnt_id:	16
ino:	1585339

=== Content of /proc/332010/fdinfo/15 ===
pos:	0
flags:	02004001
mnt_id:	16
ino:	1585339

=== Content of /proc/332010/fdinfo/16 ===
pos:	0
flags:	04000
mnt_id:	16
ino:	1585340

=== Content of /proc/332010/fdinfo/17 ===
pos:	0
flags:	04001
mnt_id:	16
ino:	1585340

=== Content of /proc/332010/fdinfo/18 ===
pos:	0
flags:	0100000
mnt_id:	0
ino:	114192

=== Content of /proc/332010/fdinfo/19 ===
pos:	0
flags:	02000001
mnt_id:	16
ino:	1567666

=== Content of /proc/332010/fdinfo/2 ===
pos:	0
flags:	02
mnt_id:	10
ino:	1581151
scm_fds: 0

=== Content of /proc/332010/fdinfo/20 ===
pos:	0
flags:	04002
mnt_id:	10
ino:	1683969
scm_fds: 0

=== Content of /proc/332010/fdinfo/21 ===
pos:	0
flags:	02004002
mnt_id:	17
ino:	2083
eventfd-count:                0
eventfd-id: 66
eventfd-semaphore: 0

=== Content of /proc/332010/fdinfo/22 ===
pos:	0
flags:	04000
mnt_id:	16
ino:	1586447

=== Content of /proc/332010/fdinfo/23 ===
pos:	0
flags:	04001
mnt_id:	16
ino:	1586447

=== Content of /proc/332010/fdinfo/24 ===
pos:	0
flags:	0100002
mnt_id:	1675
ino:	568
drm-driver:	amdgpu
drm-client-id:	1701
drm-pdev:	0000:2d:00.0
pasid:	32793
drm-memory-vram:	12 KiB
drm-memory-gtt: 	2048 KiB
drm-memory-cpu: 	0 KiB
amd-memory-visible-vram:	12 KiB
amd-evicted-vram:	0 KiB
amd-evicted-visible-vram:	0 KiB
amd-requested-vram:	12 KiB
amd-requested-visible-vram:	0 KiB
amd-requested-gtt:	2048 KiB
drm-shared-vram:	0 KiB
drm-shared-gtt:	0 KiB
drm-shared-cpu:	0 KiB

=== Content of /proc/332010/fdinfo/25 ===
pos:	0
flags:	02
mnt_id:	10
ino:	1583739
scm_fds: 0

=== Content of /proc/332010/fdinfo/26 ===
pos:	0
flags:	04002
mnt_id:	10
ino:	1691316
scm_fds: 0

=== Content of /proc/332010/fdinfo/28 ===
pos:	0
flags:	02100002
mnt_id:	1675
ino:	568
drm-driver:	amdgpu
drm-client-id:	1704
drm-pdev:	0000:2d:00.0
pasid:	32795
drm-memory-vram:	53336 KiB
drm-memory-gtt: 	6700 KiB
drm-memory-cpu: 	0 KiB
amd-memory-visible-vram:	53336 KiB
amd-evicted-vram:	0 KiB
amd-evicted-visible-vram:	0 KiB
amd-requested-vram:	53336 KiB
amd-requested-visible-vram:	43852 KiB
amd-requested-gtt:	6700 KiB
drm-shared-vram:	0 KiB
drm-shared-gtt:	0 KiB
drm-shared-cpu:	0 KiB
drm-engine-gfx:	80699202 ns
drm-engine-dec:	5469423734 ns

=== Content of /proc/332010/fdinfo/3 ===
pos:	0
flags:	02000000
mnt_id:	16
ino:	1567666

=== Content of /proc/332010/fdinfo/33 ===
pos:	0
flags:	02100002
mnt_id:	1675
ino:	568
drm-driver:	amdgpu
drm-client-id:	1705
drm-pdev:	0000:2d:00.0
pasid:	32796
drm-memory-vram:	12 KiB
drm-memory-gtt: 	2048 KiB
drm-memory-cpu: 	0 KiB
amd-memory-visible-vram:	12 KiB
amd-evicted-vram:	0 KiB
amd-evicted-visible-vram:	0 KiB
amd-requested-vram:	12 KiB
amd-requested-visible-vram:	0 KiB
amd-requested-gtt:	2048 KiB
drm-shared-vram:	0 KiB
drm-shared-gtt:	0 KiB
drm-shared-cpu:	0 KiB

=== Content of /proc/332010/fdinfo/34 ===
pos:	0
flags:	02100002
mnt_id:	1675
ino:	568
drm-driver:	amdgpu
drm-client-id:	1705
drm-pdev:	0000:2d:00.0
pasid:	32796
drm-memory-vram:	12 KiB
drm-memory-gtt: 	2048 KiB
drm-memory-cpu: 	0 KiB
amd-memory-visible-vram:	12 KiB
amd-evicted-vram:	0 KiB
amd-evicted-visible-vram:	0 KiB
amd-requested-vram:	12 KiB
amd-requested-visible-vram:	0 KiB
amd-requested-gtt:	2048 KiB
drm-shared-vram:	0 KiB
drm-shared-gtt:	0 KiB
drm-shared-cpu:	0 KiB

=== Content of /proc/332010/fdinfo/36 ===
pos:	0
flags:	02100002
mnt_id:	1675
ino:	568
drm-driver:	amdgpu
drm-client-id:	1705
drm-pdev:	0000:2d:00.0
pasid:	32796
drm-memory-vram:	12 KiB
drm-memory-gtt: 	2048 KiB
drm-memory-cpu: 	0 KiB
amd-memory-visible-vram:	12 KiB
amd-evicted-vram:	0 KiB
amd-evicted-visible-vram:	0 KiB
amd-requested-vram:	12 KiB
amd-requested-visible-vram:	0 KiB
amd-requested-gtt:	2048 KiB
drm-shared-vram:	0 KiB
drm-shared-gtt:	0 KiB
drm-shared-cpu:	0 KiB

=== Content of /proc/332010/fdinfo/4 ===
pos:	0
flags:	04002
mnt_id:	10
ino:	2100419
scm_fds: 0

=== Content of /proc/332010/fdinfo/5 ===
pos:	0
flags:	02
mnt_id:	10
ino:	1567266
scm_fds: 0

=== Content of /proc/332010/fdinfo/6 ===
pos:	0
flags:	04002
mnt_id:	10
ino:	1579665
scm_fds: 0

=== Content of /proc/332010/fdinfo/7 ===
pos:	0
flags:	02
mnt_id:	10
ino:	1567263
scm_fds: 0

=== Content of /proc/332010/fdinfo/8 ===
pos:	0
flags:	0100000
mnt_id:	1675
ino:	4

=== Content of /proc/332010/fdinfo/9 ===
pos:	0
flags:	0100000
mnt_id:	1675
ino:	4

After that, while the task is still running, please run RUST_LOG=trace .flatpak/repo/files/libexec/resources/resources-processes -o -r > /dev/null and look in stderr for this line TRACE process_data > Inspecting process x…, x being again the PID of the NPU-intensive task. Please send me all the lines following that line until the next TRACE process_data > Inspecting process, like this:

 TRACE process_data        > Inspecting process 332010…
 TRACE process_data        > Reading info files…
 TRACE process_data        > Gathering GPU stats…
 TRACE process_data        > Gathering NVIDIA GPU stats…
 TRACE process_data        > Gathering other GPU stats…
 TRACE process_data        > fdinfo 0 deemed as not plausible. Reason: fd_num ≤ 2 (probably std stream)
 TRACE process_data        > fdinfo 1 deemed as not plausible. Reason: fd_num ≤ 2 (probably std stream)
 TRACE process_data        > fdinfo 2 deemed as not plausible. Reason: fd_num ≤ 2 (probably std stream)
 TRACE process_data        > fdinfo 3 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 5 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 6 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 7 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 8 deemed as not plausible. Reason: Wrong major (expected: 226, got: 1)
 TRACE process_data        > fdinfo 9 deemed as not plausible. Reason: Wrong major (expected: 226, got: 1)
 TRACE process_data        > fdinfo 10 deemed as not plausible. Reason: Wrong major (expected: 226, got: 1)
 TRACE process_data        > fdinfo 11 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 12 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 13 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 14 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 15 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 16 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 17 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 18 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 19 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 20 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 21 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 22 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 23 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 24 deemed as plausible
 TRACE process_data        > Reading and parsing /proc/332010/fdinfo/24 for GPU stats…
 TRACE process_data        > Success reading GPU data for 0000:2d:00.0: GpuUsageStats { gfx: 0, mem: 2109440, enc: 0, dec: 0, nvidia: false }
 TRACE process_data        > fdinfo 25 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 26 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 28 deemed as plausible
 TRACE process_data        > Reading and parsing /proc/332010/fdinfo/28 for GPU stats…
 TRACE process_data        > Success reading GPU data for 0000:2d:00.0: GpuUsageStats { gfx: 73864275, mem: 23597056, enc: 0, dec: 3283615286, nvidia: false }
 TRACE process_data        > fdinfo 33 deemed as plausible
 TRACE process_data        > Reading and parsing /proc/332010/fdinfo/33 for GPU stats…
 TRACE process_data        > Success reading GPU data for 0000:2d:00.0: GpuUsageStats { gfx: 0, mem: 2109440, enc: 0, dec: 0, nvidia: false }
 TRACE process_data        > fdinfo 34 deemed as not plausible. Reason: kcmp indicated that we've already seen this file
 TRACE process_data        > fdinfo 36 deemed as not plausible. Reason: kcmp indicated that we've already seen this file
 TRACE process_data        > Gathering NPU stats…
 TRACE process_data        > fdinfo 0 deemed as not plausible. Reason: fd_num ≤ 2 (probably std stream)
 TRACE process_data        > fdinfo 1 deemed as not plausible. Reason: fd_num ≤ 2 (probably std stream)
 TRACE process_data        > fdinfo 2 deemed as not plausible. Reason: fd_num ≤ 2 (probably std stream)
 TRACE process_data        > fdinfo 3 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 5 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 6 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 7 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 8 deemed as not plausible. Reason: Wrong major (expected: 226, got: 1)
 TRACE process_data        > fdinfo 9 deemed as not plausible. Reason: Wrong major (expected: 226, got: 1)
 TRACE process_data        > fdinfo 10 deemed as not plausible. Reason: Wrong major (expected: 226, got: 1)
 TRACE process_data        > fdinfo 11 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 12 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 13 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 14 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 15 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 16 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 17 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 18 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 19 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 20 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 21 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 22 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 23 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 24 deemed as plausible
 TRACE process_data        > Reading and parsing /proc/332010/fdinfo/24 for NPU stats…
 TRACE process_data        > Driver 'amdgpu' is not known to be NPU-related, skipping
 TRACE process_data        > fdinfo 25 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 26 deemed as not plausible. Reason: Wrong st_mode
 TRACE process_data        > fdinfo 28 deemed as plausible
 TRACE process_data        > Reading and parsing /proc/332010/fdinfo/28 for NPU stats…
 TRACE process_data        > Driver 'amdgpu' is not known to be NPU-related, skipping
 TRACE process_data        > fdinfo 33 deemed as plausible
 TRACE process_data        > Reading and parsing /proc/332010/fdinfo/33 for NPU stats…
 TRACE process_data        > Driver 'amdgpu' is not known to be NPU-related, skipping
 TRACE process_data        > fdinfo 34 deemed as not plausible. Reason: kcmp indicated that we've already seen this file
 TRACE process_data        > fdinfo 36 deemed as not plausible. Reason: kcmp indicated that we've already seen this file

@ThatOneCalculator
Copy link
Author

Will be able to test tomorrow!

@nokyan
Copy link
Owner

nokyan commented Dec 22, 2024

Have you had the chance to test it yet? :)

@nokyan nokyan linked a pull request Jan 4, 2025 that will close this issue
@nokyan
Copy link
Owner

nokyan commented Jan 31, 2025

I'd really like to merge this, is there someone who has a new AMD CPU with an NPU who could test this?

@Nikitf777
Copy link

Nikitf777 commented Feb 4, 2025

Is it supposed to work with the new Linux built-in amdxdna driver? I updated to 6.14 rc1 recently, but there is no any NPU tab (but there is in Windows Task Manager).

Image

@nokyan
Copy link
Owner

nokyan commented Feb 4, 2025

Is it supposed to work with the new Linux built-in amdxdna driver? I updated to 6.14 rc1 recently, but there is no any NPU tab (but there is in Windows Task Manager).

Yes, it's for amdxdna. Can you check using modinfo amdxdna whether the driver is loaded?

@Nikitf777
Copy link

Nikitf777 commented Feb 4, 2025

Yeah, it turns out that the problem is in the driver, which for some reason isn't loaded:
modinfo: ERROR: Module amdxdna not found.

@ThatOneCalculator
Copy link
Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants