jupyter-resource-usage
jupyter-resource-usage copied to clipboard
Add GPU usage?
I was just wondering if this is possible.
Also I wanted to say this extension is awesome thank you.
Ah yes this would be great! I may be able to contribute some cycles here..
@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.
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..
@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.
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 :)
No worries, thank you so much for looking into this! :)
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.
@esevan I'm interested in your awesome extension! Would you share it?
Also interested. @esevan ?