Skip to content

Commit c10f2ea

Browse files
authored
Merge pull request #30 from jtpio/readme-cpu
Add section about CPU usage to the README
2 parents 7837359 + a1a6170 commit c10f2ea

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ jupyter nbextension enable --py nbresuse --sys-prefix
3434
### Memory Limit
3535

3636
`nbresuse` can display a memory limit (but not enforce it). You can set this
37-
in serveral ways:
37+
in several ways:
3838

39-
1. `MEM_LIMIT` environment variable. This is set by [JupyterHub](http://github.com/jupyterhub/jupyterhub/)
39+
1. `MEM_LIMIT` environment variable. This is set by [JupyterHub](https://github.com/jupyterhub/jupyterhub/)
4040
if using a spawner that supports it.
4141
2. In the commandline when starting `jupyter notebook`, as `--ResourceUseDisplay.mem_limit`.
42-
3. In your jupyter notebook [traitlets](https://traitlets.readthedocs.io/en/stable/) config file
42+
3. In your Jupyter notebook [traitlets](https://traitlets.readthedocs.io/en/stable/) config file
4343

4444
The limit needs to be set as an integer in Bytes.
4545

@@ -53,7 +53,36 @@ The threshold for this warning can be configured as a fraction of the memory lim
5353
If you want to flash the warning to the user when they are within 10% of the memory limit, you
5454
can set the parameter `--ResourceUseDisplay.mem_warning_threshold=0.1`.
5555

56+
57+
### CPU Usage
58+
59+
`nbresuse` can also track CPU usage and report a `cpu_percent` value as part of the `/metrics` response.
60+
61+
You can set the `cpu_limit` in several ways:
62+
63+
1. `CPU_LIMIT` environment variable. This is set by [JupyterHub](https://github.com/jupyterhub/jupyterhub/)
64+
if using a spawner that supports it.
65+
2. In the command line when starting `jupyter notebook`, as `--ResourceUseDisplay.cpu_limit`.
66+
3. In your Jupyter notebook [traitlets](https://traitlets.readthedocs.io/en/stable/) config file
67+
68+
The limit corresponds to the number of cpus the user has access to, but does not enforce it.
69+
70+
Additionally, you can set the `track_cpu_percent` trait to enable CPU usage tracking (disabled by default):
71+
72+
```python
73+
c = get_config()
74+
c.NotebookApp.ResourceUseDisplay.track_cpu_percent = True
75+
```
76+
77+
As a command line argument:
78+
79+
```bash
80+
jupyter notebook --ResourceUseDisplay.track_cpu_percent=True
81+
```
82+
5683
## Resources displayed
5784

5885
Currently it only displays Memory usage (just RSS). Other metrics will be
59-
added in the future as needed.
86+
added in the future as needed.
87+
88+
The notebook extension currently doesn't show CPU usage.

0 commit comments

Comments
 (0)