A simple utility to track and log peak CPU and GPU memory usage of a function.
Project description
memtracker
memtracker is a simple Python package to track and optionally log the peak CPU and GPU memory usage of a function.
- It would print the result at teminal
Peak CPU Memory for main: 491.31 MB
Peak GPU Total Memory for main: 0.00 MB
Runtime for main: 1.81 sec
- It would generate a json file, if you set
export_to_json=True
{
"function_name": "main",
"function_runtime_sec": 1.6997389793395996,
"peak_cpu_memory_MB": 490.46875,
"peak_gpu_total_memory_MB": 0
}
Installation
pip install memtracker
Usage
from memtracker.memory_sampler import track_peak_memory
#Then, use the track_peak_memory decorator on your function:
@track_peak_memory()
def my_function():
# Your function logic here
pass
- To export the memory metrics to a JSON file:
@track_peak_memory(export_to_json=True)
def another_function():
# Your function logic here
pass
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
memtracker-0.1.3.tar.gz
(4.0 kB
view details)
File details
Details for the file memtracker-0.1.3.tar.gz.
File metadata
- Download URL: memtracker-0.1.3.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
452849c3e03427e66f424f232e22a048d84664af00c10401dadc00ff53c26ac5
|
|
| MD5 |
ea2cd8eadc2ec1f082aa41f3946b5f57
|
|
| BLAKE2b-256 |
8ba104d20ee01136a5ad63374538bcff0a3f56b0d3cfaf300297cf3ef8a6cbac
|