Syllo / nvtop

GPU & Accelerator process monitoring for AMD, Apple, Huawei, Intel, NVIDIA and Qualcomm
Other
7.7k stars 282 forks source link

Apple platform & GPU support #233

Closed Snektron closed 9 months ago

Snektron commented 11 months ago

This PR adds some experimental support for building on Mac OS and showing GPU information obtained via Metal. Much information is still missing, but some stuff already works and is already useful:

Of the information that is still missing, some is theoretically possible to query. For example the GPU clock can be shown using powermetrics, but this seems to call into some Apple internal API. Some indication of per-process GPU utilization can also be fetched in the AGXDeviceUserClient class (see ioreg -l | grep AGXDeviceUserClient -A10), though I didn't find anything to track per-process GPU memory use. For now NVTOP only displays the host memory use here.

Tested on a M2 running Mac OS X Ventura 13.4. When implementing I saw some things about stuff being only supported from a certain Mac version, but I don't really have the means to try that out. I think everything should be fine from version 11 or so.

I had to fix something related to testing linker flags (check_c_compiler_flags does not work for linker flags) and used check_linker_flag instead, but this is only available from CMake 3.18. Feel free to let me know if this bumping CMake to this version is undesired, I think we can backport it relatively easily.

Screeny: image

(Note that the cmdline / memory usage / cpu usage cannot be fetched for processes of a higher privilege. It works fine when running as root, but it doesn't really add anything).

Snektron commented 11 months ago

Because I could only test on a M2 with an integrated GPU im not sure how this will behave on other systems. While the error handling should catch most unexpected cases, it would be useful is somebody is able to to test some more. Specifically im interested in:

iPhones and whatever are out of scope for now.

Syllo commented 9 months ago

Seems to be working okay-ish on an Intel+Radeon Pro Macbook. It doesn't show the memory usage or any processes (I guess that it's not using metal and hence will not show these metrics). Still, better than nothing :wink:. Thank you very much.

Snektron commented 9 months ago

Did you try with elevated permissions? That seems required. Its not ideal, I know.

Whats this merge waiting on currently?

Syllo commented 9 months ago

Nothing even with elevated privileges. It's a 2019 MacBook Pro with Intel i9 & Radeon Pro 5500M.