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

GPU Widget #42

Closed
xxxserxxx opened this issue Feb 15, 2020 · 25 comments
Closed

GPU Widget #42

xxxserxxx opened this issue Feb 15, 2020 · 25 comments
Assignees
Labels
enhancement New feature or request

Comments

@xxxserxxx
Copy link
Owner

It would be nice to see GPU usage widget, using intel_gpu_top or nvidia-smi. I know that both arent' supported on some devices but if it is supported it would be nice to see. Now I have to open a special tab for intel_gpu_top:

intel-gpu-top -  755/ 755 MHz;    0% RC6;  6.57 Watts;      229 irqs/s

      IMC reads:   ------ (null)/s
     IMC writes:   ------ (null)/s

          ENGINE      BUSY                                                                                MI_SEMA MI_WAIT
     Render/3D/0   54.49% |█████████████████████████████████████████▉                                   |      0%      0%
       Blitter/0    0.00% |                                                                             |      0%      0%
         Video/0    0.00% |                                                                             |      0%      0%
  VideoEnhance/0    0.00% |                                                                             |      0%      0%

intel_gpu_top source code | nvidia smi wrapper for golang

@xxxserxxx
Copy link
Owner Author

Clone cjbassi#170
@talentlessguy FYI

@xxxserxxx xxxserxxx added the enhancement New feature or request label Feb 19, 2020
@talentlessguy
Copy link

@xxxserxxx why cloning the issue btw? 🤔

@xxxserxxx
Copy link
Owner Author

@talentlessguy Caleb is not maintaining gotop any longer, but also doesn't want anybody else maintaining his repository, nor is he comfortable with moving issues. I'm continuing development and maintenance of gotop, so I've forked and copied the tickets so that I can keep working on them.

See this issue for more information.

@xxxserxxx
Copy link
Owner Author

@talentlessguy there have been new releases, as well.

@talentlessguy
Copy link

@xxxserxxx ok, thanks for information

@xxxserxxx
Copy link
Owner Author

A couple of NVidia merge requests have been made; one of them crashes gotop and the other spikes the CPU. They both use the same library to get information. There's a C binding from NVIDIA that also might work; I'll give it a try, although I don't have an NVidia card to test against.

@talentlessguy
Copy link

@xxxserxxx there are other GPUs that imo need to be supported - AMD and Intel.

Intel GPU has a top utility already but it is better to make / use a go binding for getting values for drawing a widget

@xxxserxxx
Copy link
Owner Author

xxxserxxx commented Feb 21, 2020

If you're willing to be a tester, please respond to this ticket with the card you have access to.

  • AMD
  • Intel
  • NVidia

@talentlessguy
Copy link

@xxxserxxx

  • Intel
  • type: integrated
  • Model: 4th Gen Core Processor
  • driver: i915
  • NVIDIA
  • type: discrete
  • model: 740M
  • driver: 435

@xxxserxxx xxxserxxx added this to the v3.4.0 milestone Feb 25, 2020
@xxxserxxx xxxserxxx self-assigned this Feb 25, 2020
@xxxserxxx
Copy link
Owner Author

xxxserxxx commented Feb 25, 2020

As I'm working on this, a couple of things are coming to mind:

  1. I'm going to integrate the metrics with existing widgets rather than creating new ones. This will keep the UI less cluttered. So % use will show up in CPU, temp will show up in the temp widget, and %mem use will show up in the memory widget. Some GPU interfaces also provide TXN data, which could go in the net widget.
  2. Use of the pure Go NVIDIA library drastically increases CPU use, so I'm trying the native library. This puts a CGO dependency on gotop, and sucks in a huge number of (sometimes strange) dependencies... like etcd. I'm not liking the options so far, so I may look at the process fork approach.
  3. There is no Go library for intel or AMD that I can find, so I'm probably going to have to go the process fork approach for those anyway.

Flagging for the v3.4.0 release.

@talentlessguy
Copy link

@xxxserxxx that sucks that there are no native go libs for AMD GPU an that nvidia sucks a lot of CPU.

implementing GPU integration is a tough task, but if it will appear in gotop it will be one of the first top-like tools to also show GPU ❤️

@xxxserxxx
Copy link
Owner Author

For posterity: https://github.com/ChrisCummins/intel-gpu-tools, and other tools suggested by @talentlessguy . I'm closing #52 in favor of this, as it has broader scope.

From what I've learned in the past couple of days, I should be able to get temperature, processing usage, and memory usage for at least NVIDIA, and some subset of those for Intel. I haven't made any progress with AMD yet. ssimunic/gosensors looks promising!

@xxxserxxx xxxserxxx removed this from the v3.5.0 milestone Mar 7, 2020
@xxxserxxx
Copy link
Owner Author

Clearing the milestone. Support is in the current v3.5.0, and the actual device will be released separately as an extension. Leaving open until that's released.

@cpebble
Copy link

cpebble commented May 19, 2020

I'm interested in the status of nvidia gpu support. Is there any support i can offer?
CPU: intel i5
GPU: Nvidia gtx 1080
Uname -a: Linux partyVan 5.3.0-51-generic #44-Ubuntu SMP Wed Apr 22 21:09:44 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

@xxxserxxx
Copy link
Owner Author

@mrcpj1998, @ionlights, I'm prepping for the v4.0.0 release and have new NVidia code. Would you mind trying it and letting me know how it works (or doesn't)? A binary is available in the gotop-builder project.

This depends on the nvidia-smi tool.

Thank you.

talentlessguy, I tried not tagging you but since you responded to this ticket you may get an email. Sorry for the duplicate message.

@xxxserxxx xxxserxxx added this to the v4.2.0 milestone Jun 2, 2020
@xxxserxxx
Copy link
Owner Author

So, I like the idea of a GPU widget, but it seems like it'll only be useful for NVidia. There are no Intel GPU libraries for Go available (that I can find), and the tool set is not suited for the "execute-and-parse" model -- the intel_gpu_top program doesn't have a "print once and exit" mode. Furthermore, the Intel tools all require running as root, as does library access. This makes supporting Intel (a) more difficult, and (b) more narrow use, as it'd require running gotop as root.

There are some universal options I can explore on Linux by accessing the devices directly through /sys/class/drm/card*; something similar would be needed for all of the other OSes.

I'm not going to close this; nearly everybody has some sort of GPU. A solution that works with all vendor cards, on all OSes, is going to take some time, so I'm taking it out of the release plan for now.

@xxxserxxx xxxserxxx removed this from the v4.2.0 milestone Jun 2, 2020
@cpebble
Copy link

cpebble commented Jun 2, 2020

Just to update. I tried the linked release, and it loads for about a second then exits uncleanly.
By uncleanly i mean, the terminal emulator starts writing mouse commands as escape codes, has no cursor and can't be cleared/exited with C-l or C-c or C-d.

I don't know how to provide more detailed error reports

@xxxserxxx
Copy link
Owner Author

@mrcpj1998 that's what I like to hear! Total chaos.

If you can type at all, try a reset. It should clear the terminal up, although it won't give you any more information. Can you please paste the output of

cat $(gotop --list paths | tail -1 | cut -d' ' -f6)

or if it's too long, attach it?

Do you have nvidia-smi installed?

@xxxserxxx
Copy link
Owner Author

All, releases now trigger the building of a Linux binary with NVidia support. Let me know if it works (or doesn't work) for you.

@mrcpj1998, I found the issue and believe I've resolved it.

@xgdgsc
Copy link

xgdgsc commented Sep 23, 2020

It' s working for me with 4 nvidia 2080Ti, Thanks.

@xgdgsc
Copy link

xgdgsc commented Oct 20, 2020

I' d sugget making gpu display disabled by default. Sometimes under a faulty gpu nvidia-smi could be slow.

@xxxserxxx
Copy link
Owner Author

@mrcpj1998, @ionlights, @talentlessguy, @xgdgsc
I've decided to pull the extensions into the main program for now, and as I don't have access to a machine with an NVidia card, would like someone to test the nvidia branch of this repo to see if the GPU support is working. I'm happy to build a binary for any tester who's willing to try it.

The extension is built-in, and just like the external extension, relies on the nvidia-smi tool being installed. It has to be enabled with a flag. Extra points for confirming that it can be enabled using the config file (by adding the linenvidia=true in the file ~/.config/gotop/config) as well as nvidiarefresh=<DURATION>, but I have a rough way of testing that part myself so it isn't critical.

Example:

git clone -b nvidia --depth 1 https://github.com/xxxserxxx/gotop.git
cd gotop
go run ./cmd/gotop --nvidia

The nvidiarefresh parameter can only be set in the config file.

If I get confirmation this works, I'll merge NVidia support into the next release.

Why?

As I've mentioned before, Go plugins are simply not practical for this (any?) use case, and my hacky solution -- while clever -- was ugly and really user unfriendly, even for people familiar with Go. Since it uses the nvidia-smi tool, this version of NVidia GPU support does not import any huge libraries and there's little reason to not include it. The one reason that does exist scares me a little: if we do find a good, cross-platform NVidia library, it'll probably be harder to use. If it has external dependencies, I won't be able to release binaries that include it, and if it's native Go and large, it'll bloat the binary unnecessarily for non-NVidia users. However, I suppose I'll have to cross that bridge when I come to it; for now, I'm planning to pursue this method.

Thank you!

@xgdgsc
Copy link

xgdgsc commented Mar 5, 2021

I tested it works.

@xxxserxxx
Copy link
Owner Author

Thanks @xgdgsc.

@luochen1990
Copy link

Hoping for an Intel iGPU support

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

No branches or pull requests

5 participants