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 GPU usage? #12

Open
JaeDukSeo opened this issue Nov 12, 2018 · 9 comments
Open

Add GPU usage? #12

JaeDukSeo opened this issue Nov 12, 2018 · 9 comments

Comments

@JaeDukSeo
Copy link

I was just wondering if this is possible.

Also I wanted to say this extension is awesome thank you.

@lmeyerov
Copy link

lmeyerov commented Feb 8, 2020

Ah yes this would be great! I may be able to contribute some cycles here..

@krinsman
Copy link
Contributor

@lmeyerov If you know how to implement this, that would be great!

It might have to be an opt-in feature for a couple versions to make sure backwards-compatibility is preserved, the way CPU usage is currently an opt-in feature.

@lmeyerov
Copy link

The core bit would be just https://pypi.org/project/nvgpu/ , so not hard -- any pointers on how to get started or what'd help push through rest of the way would be appreciated..

@krinsman
Copy link
Contributor

krinsman commented Feb 21, 2020

@lmeyerov I would love to be able to give you useful pointers. Unfortunately, when it comes to GPU's, I'm pretty sure I would have no idea what I'm talking about, since I haven't really ever used them. So what follows should probably be taken with a grain of salt.

Maybe a good idea would be to model this on the CPU percentage tracking feature?

See here: https://github.com/yuvipanda/nbresuse/blob/master/nbresuse/__init__.py#L72
where by default the CPU tracking isn't enabled, since it is (relatively speaking) an experimental feature, and one which isn't supported by default by JupyterLab or notebook yet. I imagine the same would be true of the GPU tracking.

Also, if you could make the nvgpu dependency optional, so that people who don't want/need the new GPU tracking feature don't have to install the nvgpu package. The downside to this is that it would then not be in the requirements.txt, i.e. recommended dependencies are more difficult to make explicit in Python, so an addition to the README.md noting explicitly that one will have to install nvgpu manually and change the default config to be track_gpu_percent to be true, since NBResuse doesn't have any official documentation yet other than the README.

(The last part is a little hypocritical of me though because I just realized that I myself never actually updated the README.md to note explicitly that CPU tracking is now an option, but just needs to be manually enabled by changing the config. If you want to add a note about that too to the README.md too, I would be incredibly grateful, although I would agree with you if you believe that I should be required to fix my own mistake.)

As for how to make the nvgpu dependency optional, maybe an import statement like:

try:
    import nvgpu
except ImportError:
    nvgpu = None

and then surround the code blocks with the GPU tracking with conditional statements like:

if nvgpu and config.track_gpu_percent:
    # Exciting new feature here
else:
    pass # or some other way of "doing nothing"

Finally, regarding the code structure, maybe follow the pattern that @tommassino established with the Prometheus PR? See e.g. https://github.com/yuvipanda/nbresuse/blob/master/nbresuse/metrics.py or here: https://github.com/yuvipanda/nbresuse/blob/master/nbresuse/prometheus.py
I think @tommassino is much more qualified than I am to talk about what aspects of that code are most important to emulate, although I will note in passing that I like the use of typing and the creation of explicit types, e.g. like in Tornado's code -- I think that could be very helpful for increasing the duration of NBResuse's long-term maintainability.

@lmeyerov
Copy link

Thanks, I'll look into this!

And yes, I'm guessing we can do something like pip install nbresuse[gpu,prometheus,...] and whatever the conda equiv is. Warning that it'll be... slow.. as we have other things that also have to happen on our side :)

@krinsman
Copy link
Contributor

No worries, thank you so much for looking into this! :)

@esevan
Copy link

esevan commented Jun 8, 2020

Any progress on this?

I've been forwarded from https://discourse.jupyter.org/t/detecting-cpu-and-ram-limits-on-mybinder-org/4640/2 .

If no progress so far, I can create a PR for this.
image

@AeroXi
Copy link

AeroXi commented Aug 29, 2021

@esevan I'm interested in your awesome extension! Would you share it?

@ihleonard-c3
Copy link

Also interested. @esevan ?

davidbrochart pushed a commit to davidbrochart/jupyter-resource-usage that referenced this issue Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants