Syllo / nvtop

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

FreeBSD: Full Functionality In 20 Characters (non-issue) #121

Closed thesunexpress closed 2 years ago

thesunexpress commented 2 years ago

Hello All,

First off, I do not wish for any recognition, nether credit nor any epic 1337-5Ki11Z points, on account of this being the easiest 'fix' I've ever made to a Linux app, to get it to work as intended on FreeBSD. So far I have limited running on just 2 FreeBSD 13.0 boxes (official NVidia driver installed) with NVidia GeForce GT 1030 GPUs, one by EVGA & one Asus -- both are fanless as I do not need serious GPU horsepower. Interestingly, on the box furnished with the EVGA GPU, it indicates fan usage when there is no fan present at all. The official nvidia-settings (GUI) / nvidia-smi (CLI) app does not reflect any fan activity. It somewhat randomly jumps from indicating 35% to 37% to 43% fan-speed(??) for no particular reason; other than that, everything works fine & all indicators report correctly. The Asus GT 1030 GPU correctly indicates "N/A %" for the fan speed, as reflected by the official NVidia apps. I have a box with a Quadro K-series GPU to test, coming up next.

How To:

$ git clone https://github.com/Syllo/nvtop.git $ cd nvtop $ ee src/interface.c (or $ nano src/interface.c if you prefer that, but why?!) --- Scroll down a bit, add the following line right below the line ' #include nvtop/time.h @ line 32. --- #define SIGPWR SIGINFO @ line 33 --- Yes, really, it is just 20 characters. --- Save & exit. $ mkdir build && cd build $ cmake .. $ make (you can use gmake too, if so inclined, but default works fine) --- The ' nvtop ' executable, if successfully compiled, can now be found at ' nvtop/build/src/nvtop ' and run from there to test. --- You may now elect to install the app with: $ sudo make install or $ doas make install --- The ' doas ' command is something us nerdy BSD'ers use. Linux could benefit from this original OpenBSD app.

Bit of background info on the shenanigans of defining the "SIGPWR" to "SIGINFO" thing... As you may guess, (Free)BSD does not use this signal. As I understand it, the "translated" term from Linux to BSD, indicates that "SIGINFO" can be used in its stead. There appears to also be the option to use signal "29" for BSD as well. Thus using the line #define SIGPWR 29 seems to work as well. I'm not 1000000% convinced that using ' 29 ' is entirely kosher, so for what it's worth, stick with "SIGINFO". I tend to prefer the minimal modification to source code route. Documentation suggests the two signals may not be completely compatible in all circumstances. I am not specifically certain how nvtop uses this signal on Linux, but so far I have been unable to cause the app to crash in any way; so all seems good. A more elegant #ifdef routine could be implemented, to check for a BSD Operating System & based on its identification issue the SIG switch... but I'll leave that decision to the Developer.

Finally, many thanks to Syllo for all the work you've done for this fantastic little piece of software!!

Edit: Been running the app for 12+ hours on all boxes & monitoring the-goings-on it looks like it happily consuming no more than ~8 MB RAM, CPU utilization is low enough that it scarcely registers i.e. < 00.1%

Edit2: I can confirm my modifications work on NVidia Quadro K-series cards. Next, I just tested a quick-n-easy mod that I can confirm works on both FreeBSD and Arch Linux & ArchLabs: Substitute the previous FreeBSD specific line #define SIGPWR SIGINFO in src/interface.c with:

#ifdef __FreeBSD__ #define SIGPWR SIGINFO #endif

Or

#if defined(__FreeBSD__) #define SIGPWR SIGINFO #endif

The 2 options placed up ^^^ there are out of concern certain compilers may complain. I cannot be sure. Compilation proceeds without the slightest hitch on both FreeBSD & Arch Linux. It couldn't be easier. Again, I shall leave it up to the Developer to actually include the modification.

Syllo commented 2 years ago

Thanks a lot for the explanation and contribution.

Fixed in 39db844edced804439e002790f2d4bfa63f348d4

I set you as author (although I don't know your email address). You'll need to live with all the fame that comes out of this commit :wink:

rajhlinux commented 1 year ago

Does this mean NVTOP is now compatible with FreeBSD?