Package: jupyter-probe
Jupyter ProbeJupyterprobe is a python package to monitor, manage, declare and analyse notebook resource usage on jupyter environments.CompatibilityJupyterprobe works with Linux, OSX. Wide variety of Jupyter environment flavours and configurations are supported:Jupyter Notebook, Jupyter LabAuthentication: None, Token, PasswordHosted at: localhost, remoteGPU is also supported (requires Nvidia Management Library (NVML)/ CUDA toolkit).Jupyterprobe currently works with Python 3.6.1 or later.InstallingInstall withpipor your favorite PyPi package manager.pip install jupyter-probe(For common troubleshooting, see here)UsageNote: All these commands are to be run from within your jupyter notebooks.Define ProbeFirst define aProbeobject using host and port.fromjupyterprobeimportProbehost='localhost'port=8888pb=Probe(host,port)If your jupyter environment is password authenticated, you can additionally pass the password argumentpb=Probe(host,port,password='hobbit')MonitorTo monitor resource usage of all notebooks in your session, callMonitor.pb.Monitor()Top 5 results are shown sorted by memory usage. To see more, you can pass top_n as argumentpb.Monitor(10)Declare ExperimentTo declare ownershippb.Declare(owner='Gandalf',priority='10',project='Ring')This will save the declaration for your current notebook in~/.jupyterprobe/experiment_register.json.Monitor TeamBy default, monitor only shows resource usage and PID of your notebooks. To see ownership and project related data, useMonitorTeamorMonitor(team=true)pb.MonitorTeam()This will show details based on your declarations as well as declarations from other teammates using the same Jupyter Session.Custom Usage AnalyticsIf you want to do your own analytics on notebooks' usage, you can get Pandas Dataframe of all the results throughpb.results.Some more usefull methods that can be called upon Probeobject:get_results_by_PID(PID): get all results of notebook matching given PIDget_results_by_name(name): get all results of notebook matching given name. Returns multiple notebooks if name isn't uniqueget_path_by_PID(PID): get absolute path of notebook matching given PIDget_path_by_name(name): get absolute path of notebook matching given name. Returns multiple paths if name isn't uniqueTroubleshootingCan't install psutil, python.h not found:
You need to install python-dev. For Unix like systems, you can dosudo apt-get install python3.x-devwherepython3.xrefers to your python version.INFO: GPU not found on your system, but you actually have GPU: Installpy3nvmland runimport py3nvml
py3nvml.py3nvml.nvmlInit()Most probably, your Nvidia libraries are missing due to which it will throw an error.Could not detect any jupyter servers from your kernel: This can happen if you have multiple ipython kernels and you have only installed jupyterprobe in one of them.
The best way possible is to uninstall and install jupyter and jupyterlab packages.python3.x -m pip uninstall jupyter jupyterlab
python3.x -m pip install jupyter jupyterlabIf this doesn't work either, you can try removing the ipython kernel, install it again and then repeat the above steps.jupyter kernelspec list
jupyter kernelspec remove <kernel-name>
python3.x -m pip install ipykernel
python3.x -m ipykernel install --userAdditionally, to check if your kernel can find notebook servers, runfromnotebookimportnotebookappservers=list(notebookapp.list_running_servers())print(servers)If your kernel is correctly setup, you should see jupyter server information. If you get an error, or an empty list, try above steps.Issues and ContributingThe project is still in active development. If you face any error or want to request a feature, feel free to open an issue. Additionally, if you want to contribute, a PR is always welcome.Thenvidia-smiconundrumnvidia-smiis a great command to check GPU usage and state for your system. However, if the system you are using is in a container, when you runnvidia-smi, you will see correct GPU memory usage but process IDs and names might not come up. This can happen becausenvidia-smiuses hardware levelnvmllibrary which exposes PIDs as defined on host system. But PIDs change on container and thus process names can't be found. As a result,nvidia-smidoesn't yield process level information.Jupyterprobe solves this issue by mapping back from host PIDs to container PIDs. However, currently, this only works on Unix based systems (which have process information in /proc).