resources icon indicating copy to clipboard operation
resources copied to clipboard

Add full support for AMD NPUs

Open ThatOneCalculator opened this issue 1 year ago • 37 comments

Is there an existing issue for this?

  • [X] 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 avatar Dec 10 '24 06:12 ThatOneCalculator

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

nokyan avatar Dec 10 '24 12:12 nokyan

xdna-driver supports drm usage stats (fdinfo).

https://github.com/amd/xdna-driver/pull/262

Umio-Yasuno avatar Dec 10 '24 23:12 Umio-Yasuno

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),
    }
}

ThatOneCalculator avatar Dec 11 '24 01:12 ThatOneCalculator

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.

Umio-Yasuno avatar Dec 11 '24 03:12 Umio-Yasuno

Do you mind trying out the amdxdna-support branch?

nokyan avatar Dec 14 '24 18:12 nokyan

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

npu_resources_test.webm

ThatOneCalculator avatar Dec 14 '24 20:12 ThatOneCalculator

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

nokyan avatar Dec 14 '24 21:12 nokyan

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)

ThatOneCalculator avatar Dec 14 '24 21:12 ThatOneCalculator

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.

nokyan avatar Dec 14 '24 21:12 nokyan

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

ThatOneCalculator avatar Dec 14 '24 21:12 ThatOneCalculator

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.

nokyan avatar Dec 14 '24 21:12 nokyan

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

ThatOneCalculator avatar Dec 14 '24 21:12 ThatOneCalculator

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 avatar Dec 14 '24 21:12 nokyan

@ThatOneCalculator You can pull and try again :)

nokyan avatar Dec 14 '24 21:12 nokyan

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

image

ThatOneCalculator avatar Dec 14 '24 21:12 ThatOneCalculator

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?

nokyan avatar Dec 14 '24 21:12 nokyan

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

ThatOneCalculator avatar Dec 14 '24 21:12 ThatOneCalculator

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: {},
    )

nokyan avatar Dec 14 '24 21:12 nokyan

    (
        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,
            ),
        },
    ),

ThatOneCalculator avatar Dec 14 '24 22:12 ThatOneCalculator

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.

nokyan avatar Dec 14 '24 22:12 nokyan

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 avatar Dec 14 '24 22:12 ThatOneCalculator

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

ThatOneCalculator avatar Dec 14 '24 22:12 ThatOneCalculator

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

No problem, happens. :)

nokyan avatar Dec 14 '24 22:12 nokyan

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 avatar Dec 14 '24 22:12 ThatOneCalculator

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: {},
    ),

ThatOneCalculator avatar Dec 14 '24 22:12 ThatOneCalculator

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

nokyan avatar Dec 15 '24 09:12 nokyan

Will be able to test tomorrow!

ThatOneCalculator avatar Dec 16 '24 18:12 ThatOneCalculator

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

nokyan avatar Dec 22 '24 09:12 nokyan

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

nokyan avatar Jan 31 '25 17:01 nokyan

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

Nikitf777 avatar Feb 04 '25 11:02 Nikitf777