diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index e7bf827..77c876f 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -24,7 +24,7 @@ jobs:
- name: Install testing environment
run: |
python3 -m pip install --upgrade pip
- python3 -m pip install pytest pytest-mock pytest-cov
+ python3 -m pip install pytest pytest-mock pytest-cov deepdiff
- name: Install package
uses: Wandalen/wretry.action@master
with:
diff --git a/README.rst b/README.rst
index 9e32de0..eaf3ca1 100644
--- a/README.rst
+++ b/README.rst
@@ -5,7 +5,7 @@ Description
-----------
The ``gpu_tracker`` package provides a ``Tracker`` class and a commandline-interface that tracks (profiles) the usage of compute time, CPU utilization, maximum RAM, GPU utilization, and maximum GPU RAM.
The compute time is a measurement of the real time taken by the task as opposed to the CPU-utilization time.
-The GPU tracking is for Nvidia GPUs and uses the ``nvidia-smi`` command. If the Nvidia drivers have not been installed, then the max GPU RAM is not tracked and measurements are reported as 0.
+The GPU tracking is for both Nvidia and AMD GPUs and respectively uses the nvidia-smi and amd-smi command-line tools to pull GPU usage information. Also, if neither the appropriate Nvidia nor AMD driver is installed, then the GPU-related metrics are not tracked and are reported as 0.
Computational resources are tracked throughout the duration of a context manager or the duration of explicit calls to the ``start()`` and ``stop()`` methods of the ``Tracker`` class.
The ``gpu-tracker`` command-line interface alternatively tracks the computational-resource-usage of an arbitrary shell command.
diff --git a/docs/conf.py b/docs/conf.py
index 966388d..f9917a8 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -14,8 +14,8 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'gpu_tracker'
-copyright = '2024, Erik Huckvale, Hunter N. B. Moseley'
-author = 'Erik Huckvale, Hunter N. B. Moseley'
+copyright = '2024, Erik D. Huckvale, Hunter N. B. Moseley'
+author = 'Erik D. Huckvale, Hunter N. B. Moseley'
version = __version__
release = __version__
diff --git a/docs/notebook/combined-file.csv b/docs/notebook/combined-file.csv
new file mode 100644
index 0000000..458c334
--- /dev/null
+++ b/docs/notebook/combined-file.csv
@@ -0,0 +1,25 @@
+process_id,code_block_name,position,timestamp
+265016,my-code-block,0,1746129778.99568
+265016,my-code-block,1,1746129781.7855892
+265016,my-function,0,1746129781.7872624
+265016,my-function,1,1746129784.3252733
+265016,my-code-block,0,1746129784.3266726
+265016,my-code-block,1,1746129786.9071054
+265016,my-function,0,1746129786.9082048
+265016,my-function,1,1746129789.4858837
+265016,my-code-block,0,1746129789.486994
+265016,my-code-block,1,1746129792.0702057
+265016,my-function,0,1746129792.0713246
+265016,my-function,1,1746129794.6151624
+265016,my-code-block,0,1746129778.99568
+265016,my-code-block,1,1746129781.7855892
+265016,my-function,0,1746129781.7872624
+265016,my-function,1,1746129784.3252733
+265016,my-code-block,0,1746129784.3266726
+265016,my-code-block,1,1746129786.9071054
+265016,my-function,0,1746129786.9082048
+265016,my-function,1,1746129789.4858837
+265016,my-code-block,0,1746129789.486994
+265016,my-code-block,1,1746129792.0702057
+265016,my-function,0,1746129792.0713246
+265016,my-function,1,1746129794.6151624
diff --git a/docs/notebook/config.json b/docs/notebook/config.json
new file mode 100644
index 0000000..6a866e5
--- /dev/null
+++ b/docs/notebook/config.json
@@ -0,0 +1,6 @@
+{
+ "sleep_time": 0.5,
+ "ram_unit": "megabytes",
+ "gpu_ram_unit": "megabytes",
+ "time_unit": "seconds"
+}
diff --git a/docs/notebook/correct_nbconvert.py b/docs/notebook/correct_nbconvert.py
index d1765eb..23daf6a 100644
--- a/docs/notebook/correct_nbconvert.py
+++ b/docs/notebook/correct_nbconvert.py
@@ -5,6 +5,7 @@
contents: str = contents.replace('python3\n\n !', 'none\n\n !')
contents: str = contents.replace('parsed-literal::', 'code:: none')
contents: str = contents.replace('!', '$ ')
+contents: str = contents.replace('os._exit(0)', '')
contents = '.. _tutorial-label:\n\n' + contents
with open('tutorial.rst', 'w') as file:
diff --git a/docs/notebook/my-results.pkl b/docs/notebook/my-results.pkl
new file mode 100644
index 0000000..d2825f8
Binary files /dev/null and b/docs/notebook/my-results.pkl differ
diff --git a/docs/notebook/results.pkl b/docs/notebook/results.pkl
new file mode 100644
index 0000000..c2c69de
Binary files /dev/null and b/docs/notebook/results.pkl differ
diff --git a/docs/notebook/results2.pkl b/docs/notebook/results2.pkl
new file mode 100644
index 0000000..d2825f8
Binary files /dev/null and b/docs/notebook/results2.pkl differ
diff --git a/docs/notebook/sub-tracking.csv b/docs/notebook/sub-tracking.csv
new file mode 100644
index 0000000..b2037f1
--- /dev/null
+++ b/docs/notebook/sub-tracking.csv
@@ -0,0 +1,13 @@
+process_id,code_block_name,position,timestamp
+265016,my-code-block,0,1746129778.99568
+265016,my-code-block,1,1746129781.7855892
+265016,my-function,0,1746129781.7872624
+265016,my-function,1,1746129784.3252733
+265016,my-code-block,0,1746129784.3266726
+265016,my-code-block,1,1746129786.9071054
+265016,my-function,0,1746129786.9082048
+265016,my-function,1,1746129789.4858837
+265016,my-code-block,0,1746129789.486994
+265016,my-code-block,1,1746129792.0702055
+265016,my-function,0,1746129792.0713246
+265016,my-function,1,1746129794.6151624
diff --git a/docs/notebook/sub-tracking1.csv b/docs/notebook/sub-tracking1.csv
new file mode 100644
index 0000000..b2037f1
--- /dev/null
+++ b/docs/notebook/sub-tracking1.csv
@@ -0,0 +1,13 @@
+process_id,code_block_name,position,timestamp
+265016,my-code-block,0,1746129778.99568
+265016,my-code-block,1,1746129781.7855892
+265016,my-function,0,1746129781.7872624
+265016,my-function,1,1746129784.3252733
+265016,my-code-block,0,1746129784.3266726
+265016,my-code-block,1,1746129786.9071054
+265016,my-function,0,1746129786.9082048
+265016,my-function,1,1746129789.4858837
+265016,my-code-block,0,1746129789.486994
+265016,my-code-block,1,1746129792.0702055
+265016,my-function,0,1746129792.0713246
+265016,my-function,1,1746129794.6151624
diff --git a/docs/notebook/sub-tracking2.csv b/docs/notebook/sub-tracking2.csv
new file mode 100644
index 0000000..b2037f1
--- /dev/null
+++ b/docs/notebook/sub-tracking2.csv
@@ -0,0 +1,13 @@
+process_id,code_block_name,position,timestamp
+265016,my-code-block,0,1746129778.99568
+265016,my-code-block,1,1746129781.7855892
+265016,my-function,0,1746129781.7872624
+265016,my-function,1,1746129784.3252733
+265016,my-code-block,0,1746129784.3266726
+265016,my-code-block,1,1746129786.9071054
+265016,my-function,0,1746129786.9082048
+265016,my-function,1,1746129789.4858837
+265016,my-code-block,0,1746129789.486994
+265016,my-code-block,1,1746129792.0702055
+265016,my-function,0,1746129792.0713246
+265016,my-function,1,1746129794.6151624
diff --git a/docs/notebook/tracking.csv b/docs/notebook/tracking.csv
new file mode 100644
index 0000000..b83e7c5
--- /dev/null
+++ b/docs/notebook/tracking.csv
@@ -0,0 +1,28 @@
+ram_unit,gpu_ram_unit,time_unit,ram_system_capacity,gpu_ram_system_capacity,system_core_count,n_expected_cores,system_gpu_count,n_expected_gpus
+gigabytes,gigabytes,hours,67.254165504,16.376,12,12,1,1
+main_ram,descendants_ram,combined_ram,system_ram,main_gpu_ram,descendants_gpu_ram,combined_gpu_ram,system_gpu_ram,gpu_sum_utilization_percent,gpu_hardware_utilization_percent,main_n_threads,descendants_n_threads,combined_n_threads,cpu_system_sum_utilization_percent,cpu_system_hardware_utilization_percent,cpu_main_sum_utilization_percent,cpu_main_hardware_utilization_percent,cpu_descendants_sum_utilization_percent,cpu_descendants_hardware_utilization_percent,cpu_combined_sum_utilization_percent,cpu_combined_hardware_utilization_percent,timestamp
+0.341860352,0.0,0.341860352,4.859711488,0.0,0.0,0.0,0.215,0.0,0.0,12,0,12,11.900000000000002,0.9916666666666668,100.3,8.358333333333333,0,0.0,100.3,8.358333333333333,1746129779.2048252
+0.731631616,0.0,0.731631616,5.008326656,0.0,0.0,0.0,0.215,0.0,0.0,12,0,12,127.5,10.625,103.1,8.591666666666667,0,0.0,103.1,8.591666666666667,1746129779.8564913
+0.661712896,0.0,0.661712896,5.115432960000001,0.0,0.0,0.0,0.218,0.0,0.0,14,0,14,116.89999999999999,9.741666666666665,79.6,6.633333333333333,0,0.0,79.6,6.633333333333333,1746129780.5009012
+0.851456,0.0,0.851456,5.207662592,0.314,0.0,0.314,0.535,0.0,0.0,15,0,15,123.1,10.258333333333333,99.2,8.266666666666667,0,0.0,99.2,8.266666666666667,1746129781.1513443
+0.912490496,0.0,0.912490496,5.279162368000001,0.314,0.0,0.314,0.535,0.0,0.0,15,0,15,124.39999999999999,10.366666666666665,101.5,8.458333333333334,0,0.0,101.5,8.458333333333334,1746129781.8066156
+0.8645918720000001,0.0,0.8645918720000001,5.239013376,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,124.3,10.358333333333333,97.1,8.091666666666667,0,0.0,97.1,8.091666666666667,1746129782.4623022
+0.9303490560000001,0.0,0.9303490560000001,5.31324928,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,133.4,11.116666666666667,100.4,8.366666666666667,0,0.0,100.4,8.366666666666667,1746129783.1200194
+0.8646123520000001,0.0,0.8646123520000001,5.274169344000001,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,125.9,10.491666666666667,100.0,8.333333333333334,0,0.0,100.0,8.333333333333334,1746129783.7685237
+0.936558592,0.0,0.936558592,5.288230912,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,122.9,10.241666666666667,98.3,8.191666666666666,0,0.0,98.3,8.191666666666666,1746129784.421019
+0.864616448,0.0,0.864616448,5.5536435200000005,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,123.39999999999999,10.283333333333333,102.7,8.558333333333334,0,0.0,102.7,8.558333333333334,1746129785.064131
+0.9364152320000001,0.0,0.9364152320000001,5.527478272000001,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,122.4,10.200000000000001,98.2,8.183333333333334,0,0.0,98.2,8.183333333333334,1746129785.716852
+0.86462464,0.0,0.86462464,5.200162816000001,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,127.4,10.616666666666667,95.2,7.933333333333334,0,0.0,95.2,7.933333333333334,1746129786.3666322
+0.9391349760000001,0.0,0.9391349760000001,5.265408000000001,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,121.8,10.15,99.4,8.283333333333333,0,0.0,99.4,8.283333333333333,1746129787.0165348
+0.8646492160000001,0.0,0.8646492160000001,5.20341504,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,130.8,10.9,103.2,8.6,0,0.0,103.2,8.6,1746129787.6673303
+0.9443737600000001,0.0,0.9443737600000001,5.268512768,0.506,0.0,0.506,0.727,3.0,3.0,15,0,15,121.9,10.158333333333333,94.7,7.891666666666667,0,0.0,94.7,7.891666666666667,1746129788.3078256
+0.864997376,0.0,0.864997376,5.209337856,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,123.0,10.25,95.9,7.991666666666667,0,0.0,95.9,7.991666666666667,1746129788.9610796
+0.8579727360000001,0.0,0.8579727360000001,5.234085888,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,114.39999999999999,9.533333333333333,87.5,7.291666666666667,0,0.0,87.5,7.291666666666667,1746129789.588663
+0.8650014720000001,0.0,0.8650014720000001,5.219196928000001,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,120.0,10.0,100.7,8.391666666666667,0,0.0,100.7,8.391666666666667,1746129790.1870134
+0.927977472,0.0,0.927977472,5.271433216,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,130.8,10.9,97.9,8.158333333333333,0,0.0,97.9,8.158333333333333,1746129790.7797492
+0.8650096640000001,0.0,0.8650096640000001,5.296881664000001,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,123.0,10.25,96.3,8.025,0,0.0,96.3,8.025,1746129791.4257803
+0.9221242880000001,0.0,0.9221242880000001,5.315219456,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,122.99999999999999,10.249999999999998,100.6,8.383333333333333,0,0.0,100.6,8.383333333333333,1746129792.0727892
+0.8650137600000001,0.0,0.8650137600000001,5.314588672,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,120.29999999999998,10.024999999999999,99.9,8.325000000000001,0,0.0,99.9,8.325000000000001,1746129792.721361
+0.9266216960000001,0.0,0.9266216960000001,5.3080064,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,120.29999999999998,10.024999999999999,94.9,7.908333333333334,0,0.0,94.9,7.908333333333334,1746129793.3718987
+0.865017856,0.0,0.865017856,5.268705280000001,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,125.7,10.475,98.5,8.208333333333334,0,0.0,98.5,8.208333333333334,1746129794.023684
+0.932110336,0.0,0.932110336,5.2950917120000005,0.506,0.0,0.506,0.727,0.0,0.0,15,0,15,121.8,10.15,78.0,6.5,0,0.0,78.0,6.5,1746129794.6729133
diff --git a/docs/notebook/tutorial.ipynb b/docs/notebook/tutorial.ipynb
index 0f31db1..4d6acae 100644
--- a/docs/notebook/tutorial.ipynb
+++ b/docs/notebook/tutorial.ipynb
@@ -16,17 +16,33 @@
"## API"
]
},
+ {
+ "cell_type": "markdown",
+ "id": "c5757429-9f80-44f2-9318-91182372ada1",
+ "metadata": {},
+ "source": [
+ "### Tracking"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "402ba04f-4773-43fc-940f-8cfe705ec487",
+ "metadata": {},
+ "source": [
+ "#### Basics"
+ ]
+ },
{
"cell_type": "markdown",
"id": "2bb9e84a-8523-4e5f-bc01-1d6b234c19a6",
"metadata": {},
"source": [
- "The `gpu_tracker` package provides the `Tracker` class which uses a subprocess to measure computational resource usage, namely the compute time, maximum CPU utilization, mean CPU utilization, maximum RAM used, maximum GPU utilization, mean GPU utilization, and maximum GPU RAM used. The `start()` method starts this process which tracks usage in the background. After calling `start()`, one can write the code for which resource usage is measured, followed by calling the `stop()` method. The compute time will be the time from the call to `start()` to the call to `stop()` and the RAM, GPU RAM, CPU utilization, and GPU utilization quantities will be the respective computational resources used by the code that's in between `start()` and `stop()`."
+ "The `gpu_tracker` package provides the `Tracker` class which uses a subprocess to measure computational resource usage, namely the compute time, maximum CPU utilization, mean CPU utilization, maximum RAM used, maximum GPU utilization, mean GPU utilization, and maximum GPU RAM used. It supports both NVIDIA and AMD GPUs. The `start()` method starts this process which tracks usage in the background. The `Tracker` class can be used as a context manager. Upon entering the context, one can write the code for which resource usage is measured. The compute time will be the time from entering the context to exiting the context and the RAM, GPU RAM, CPU utilization, and GPU utilization quantities will be the respective computational resources used by the code that's within the context."
]
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 14,
"id": "2ac7e291-08e4-4f88-a38c-02023dd813c1",
"metadata": {},
"outputs": [],
@@ -37,15 +53,13 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 15,
"id": "5ad59e55-2bde-4453-9727-2302aa8c231a",
"metadata": {},
"outputs": [],
"source": [
- "tracker = gput.Tracker(n_expected_cores=1, sleep_time=0.1)\n",
- "tracker.start()\n",
- "example_function()\n",
- "tracker.stop()"
+ "with gput.Tracker(n_expected_cores=1, sleep_time=0.1) as tracker:\n",
+ " example_function()"
]
},
{
@@ -58,7 +72,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 16,
"id": "710e11da-7a70-49fe-be6d-c1d25ce9d53f",
"metadata": {},
"outputs": [
@@ -69,19 +83,19 @@
"Max RAM:\n",
" Unit: gigabytes\n",
" System capacity: 67.254\n",
- " System: 2.001\n",
+ " System: 4.307\n",
" Main:\n",
- " Total RSS: 0.94\n",
- " Private RSS: 0.786\n",
- " Shared RSS: 0.165\n",
+ " Total RSS: 0.924\n",
+ " Private RSS: 0.755\n",
+ " Shared RSS: 0.171\n",
" Descendants:\n",
" Total RSS: 0.0\n",
" Private RSS: 0.0\n",
" Shared RSS: 0.0\n",
" Combined:\n",
- " Total RSS: 0.94\n",
- " Private RSS: 0.786\n",
- " Shared RSS: 0.165\n",
+ " Total RSS: 0.924\n",
+ " Private RSS: 0.755\n",
+ " Shared RSS: 0.171\n",
"Max GPU RAM:\n",
" Unit: gigabytes\n",
" System capacity: 16.376\n",
@@ -93,25 +107,25 @@
" System core count: 12\n",
" Number of expected cores: 1\n",
" System:\n",
- " Max sum percent: 162.3\n",
- " Max hardware percent: 13.525\n",
- " Mean sum percent: 144.283\n",
- " Mean hardware percent: 12.024\n",
+ " Max sum percent: 222.6\n",
+ " Max hardware percent: 18.55\n",
+ " Mean sum percent: 149.285\n",
+ " Mean hardware percent: 12.44\n",
" Main:\n",
- " Max sum percent: 101.4\n",
- " Max hardware percent: 101.4\n",
- " Mean sum percent: 96.7\n",
- " Mean hardware percent: 96.7\n",
+ " Max sum percent: 103.3\n",
+ " Max hardware percent: 103.3\n",
+ " Mean sum percent: 94.285\n",
+ " Mean hardware percent: 94.285\n",
" Descendants:\n",
" Max sum percent: 0.0\n",
" Max hardware percent: 0.0\n",
" Mean sum percent: 0.0\n",
" Mean hardware percent: 0.0\n",
" Combined:\n",
- " Max sum percent: 101.4\n",
- " Max hardware percent: 101.4\n",
- " Mean sum percent: 96.7\n",
- " Mean hardware percent: 96.7\n",
+ " Max sum percent: 103.3\n",
+ " Max hardware percent: 103.3\n",
+ " Mean sum percent: 94.285\n",
+ " Mean hardware percent: 94.285\n",
" Main number of threads: 15\n",
" Descendants number of threads: 0\n",
" Combined number of threads: 15\n",
@@ -121,8 +135,8 @@
" GPU percentages:\n",
" Max sum percent: 5.0\n",
" Max hardware percent: 5.0\n",
- " Mean sum percent: 0.417\n",
- " Mean hardware percent: 0.417\n",
+ " Mean sum percent: 0.385\n",
+ " Mean hardware percent: 0.385\n",
"Compute time:\n",
" Unit: hours\n",
" Time: 0.001\n"
@@ -162,18 +176,28 @@
"id": "dbf7ad83-21d0-4cd2-adbb-278fa80d2b13",
"metadata": {},
"source": [
- "The `Tracker` can alternatively be used as a context manager rather than explicitly calling `start()` and `stop()`."
+ "The `Tracker` can alternatively be used by explicitly calling its `start()` and `stop()` methods which behave the same as entering and exiting the context manager respectively."
]
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 18,
"id": "08f688f4-f1b6-41dc-91f9-76f9c7e0fdb3",
"metadata": {},
"outputs": [],
"source": [
- "with gput.Tracker() as tracker:\n",
- " example_function()"
+ "tracker = gput.Tracker()\n",
+ "tracker.start()\n",
+ "example_function()\n",
+ "tracker.stop()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "ad1d5fc4-0554-4717-9674-a435ee4e4126",
+ "metadata": {},
+ "source": [
+ "#### Arguments and Attributes"
]
},
{
@@ -181,7 +205,7 @@
"id": "7c7afe26-b2e0-4a4a-ba88-327ed6d4bb63",
"metadata": {},
"source": [
- "The units of the computational resources can be modified as desired. For example, to measure the RAM in megabytes, the GPU RAM in megabytes, and the compute time in seconds:"
+ "The units of the computational resources can be modified as desired. The following example measures the RAM in megabytes, the GPU RAM in megabytes, and the compute time in seconds."
]
},
{
@@ -196,24 +220,24 @@
"text": [
"Max RAM:\n",
" Unit: megabytes\n",
- " System capacity: 67254.17\n",
- " System: 2336.362\n",
+ " System capacity: 67254.166\n",
+ " System: 1984.791\n",
" Main:\n",
- " Total RSS: 919.99\n",
- " Private RSS: 699.384\n",
- " Shared RSS: 230.269\n",
+ " Total RSS: 873.853\n",
+ " Private RSS: 638.353\n",
+ " Shared RSS: 235.68\n",
" Descendants:\n",
" Total RSS: 0.0\n",
" Private RSS: 0.0\n",
" Shared RSS: 0.0\n",
" Combined:\n",
- " Total RSS: 919.99\n",
- " Private RSS: 699.384\n",
- " Shared RSS: 230.269\n",
+ " Total RSS: 873.853\n",
+ " Private RSS: 638.353\n",
+ " Shared RSS: 235.68\n",
"Max GPU RAM:\n",
" Unit: megabytes\n",
" System capacity: 16376.0\n",
- " System: 727.0\n",
+ " System: 728.0\n",
" Main: 506.0\n",
" Descendants: 0.0\n",
" Combined: 506.0\n",
@@ -221,25 +245,25 @@
" System core count: 12\n",
" Number of expected cores: 12\n",
" System:\n",
- " Max sum percent: 166.5\n",
- " Max hardware percent: 13.875\n",
- " Mean sum percent: 144.55\n",
- " Mean hardware percent: 12.046\n",
+ " Max sum percent: 161.6\n",
+ " Max hardware percent: 13.467\n",
+ " Mean sum percent: 145.517\n",
+ " Mean hardware percent: 12.126\n",
" Main:\n",
- " Max sum percent: 104.8\n",
- " Max hardware percent: 8.733\n",
- " Mean sum percent: 97.458\n",
- " Mean hardware percent: 8.122\n",
+ " Max sum percent: 101.5\n",
+ " Max hardware percent: 8.458\n",
+ " Mean sum percent: 98.683\n",
+ " Mean hardware percent: 8.224\n",
" Descendants:\n",
" Max sum percent: 0.0\n",
" Max hardware percent: 0.0\n",
" Mean sum percent: 0.0\n",
" Mean hardware percent: 0.0\n",
" Combined:\n",
- " Max sum percent: 104.8\n",
- " Max hardware percent: 8.733\n",
- " Mean sum percent: 97.458\n",
- " Mean hardware percent: 8.122\n",
+ " Max sum percent: 101.5\n",
+ " Max hardware percent: 8.458\n",
+ " Mean sum percent: 98.683\n",
+ " Mean hardware percent: 8.224\n",
" Main number of threads: 15\n",
" Descendants number of threads: 0\n",
" Combined number of threads: 15\n",
@@ -247,13 +271,13 @@
" System GPU count: 1\n",
" Number of expected GPUs: 1\n",
" GPU percentages:\n",
- " Max sum percent: 0.0\n",
- " Max hardware percent: 0.0\n",
- " Mean sum percent: 0.0\n",
- " Mean hardware percent: 0.0\n",
+ " Max sum percent: 3.0\n",
+ " Max hardware percent: 3.0\n",
+ " Mean sum percent: 0.25\n",
+ " Mean hardware percent: 0.25\n",
"Compute time:\n",
" Unit: seconds\n",
- " Time: 2.685\n"
+ " Time: 2.729\n"
]
}
],
@@ -284,12 +308,12 @@
"{\n",
" \"max_ram\": {\n",
" \"unit\": \"megabytes\",\n",
- " \"system_capacity\": 67254.1696,\n",
- " \"system\": 2336.3624959999997,\n",
+ " \"system_capacity\": 67254.165504,\n",
+ " \"system\": 1984.790528,\n",
" \"main\": {\n",
- " \"total_rss\": 919.9902719999999,\n",
- " \"private_rss\": 699.3838079999999,\n",
- " \"shared_rss\": 230.268928\n",
+ " \"total_rss\": 873.8529279999999,\n",
+ " \"private_rss\": 638.353408,\n",
+ " \"shared_rss\": 235.679744\n",
" },\n",
" \"descendants\": {\n",
" \"total_rss\": 0.0,\n",
@@ -297,15 +321,15 @@
" \"shared_rss\": 0.0\n",
" },\n",
" \"combined\": {\n",
- " \"total_rss\": 919.9902719999999,\n",
- " \"private_rss\": 699.3838079999999,\n",
- " \"shared_rss\": 230.268928\n",
+ " \"total_rss\": 873.8529279999999,\n",
+ " \"private_rss\": 638.353408,\n",
+ " \"shared_rss\": 235.679744\n",
" }\n",
" },\n",
" \"max_gpu_ram\": {\n",
" \"unit\": \"megabytes\",\n",
" \"system_capacity\": 16376.0,\n",
- " \"system\": 727.0,\n",
+ " \"system\": 728.0,\n",
" \"main\": 506.0,\n",
" \"descendants\": 0.0,\n",
" \"combined\": 506.0\n",
@@ -314,16 +338,16 @@
" \"system_core_count\": 12,\n",
" \"n_expected_cores\": 12,\n",
" \"system\": {\n",
- " \"max_sum_percent\": 166.5,\n",
- " \"max_hardware_percent\": 13.875,\n",
- " \"mean_sum_percent\": 144.55,\n",
- " \"mean_hardware_percent\": 12.045833333333333\n",
+ " \"max_sum_percent\": 161.60000000000002,\n",
+ " \"max_hardware_percent\": 13.466666666666669,\n",
+ " \"mean_sum_percent\": 145.51666666666668,\n",
+ " \"mean_hardware_percent\": 12.12638888888889\n",
" },\n",
" \"main\": {\n",
- " \"max_sum_percent\": 104.8,\n",
- " \"max_hardware_percent\": 8.733333333333333,\n",
- " \"mean_sum_percent\": 97.45833333333333,\n",
- " \"mean_hardware_percent\": 8.121527777777779\n",
+ " \"max_sum_percent\": 101.5,\n",
+ " \"max_hardware_percent\": 8.458333333333334,\n",
+ " \"mean_sum_percent\": 98.68333333333334,\n",
+ " \"mean_hardware_percent\": 8.22361111111111\n",
" },\n",
" \"descendants\": {\n",
" \"max_sum_percent\": 0.0,\n",
@@ -332,10 +356,10 @@
" \"mean_hardware_percent\": 0.0\n",
" },\n",
" \"combined\": {\n",
- " \"max_sum_percent\": 104.8,\n",
- " \"max_hardware_percent\": 8.733333333333333,\n",
- " \"mean_sum_percent\": 97.45833333333333,\n",
- " \"mean_hardware_percent\": 8.121527777777779\n",
+ " \"max_sum_percent\": 101.5,\n",
+ " \"max_hardware_percent\": 8.458333333333334,\n",
+ " \"mean_sum_percent\": 98.68333333333334,\n",
+ " \"mean_hardware_percent\": 8.22361111111111\n",
" },\n",
" \"main_n_threads\": 15,\n",
" \"descendants_n_threads\": 0,\n",
@@ -345,15 +369,15 @@
" \"system_gpu_count\": 1,\n",
" \"n_expected_gpus\": 1,\n",
" \"gpu_percentages\": {\n",
- " \"max_sum_percent\": 0.0,\n",
- " \"max_hardware_percent\": 0.0,\n",
- " \"mean_sum_percent\": 0.0,\n",
- " \"mean_hardware_percent\": 0.0\n",
+ " \"max_sum_percent\": 3.0,\n",
+ " \"max_hardware_percent\": 3.0,\n",
+ " \"mean_sum_percent\": 0.25,\n",
+ " \"mean_hardware_percent\": 0.25\n",
" }\n",
" },\n",
" \"compute_time\": {\n",
" \"unit\": \"seconds\",\n",
- " \"time\": 2.684972047805786\n",
+ " \"time\": 2.728560209274292\n",
" }\n",
"}\n"
]
@@ -381,7 +405,7 @@
{
"data": {
"text/plain": [
- "MaxRAM(unit='megabytes', system_capacity=67254.1696, system=2336.3624959999997, main=RSSValues(total_rss=919.9902719999999, private_rss=699.3838079999999, shared_rss=230.268928), descendants=RSSValues(total_rss=0.0, private_rss=0.0, shared_rss=0.0), combined=RSSValues(total_rss=919.9902719999999, private_rss=699.3838079999999, shared_rss=230.268928))"
+ "MaxRAM(unit='megabytes', system_capacity=67254.165504, system=1984.790528, main=RSSValues(total_rss=873.8529279999999, private_rss=638.353408, shared_rss=235.679744), descendants=RSSValues(total_rss=0.0, private_rss=0.0, shared_rss=0.0), combined=RSSValues(total_rss=873.8529279999999, private_rss=638.353408, shared_rss=235.679744))"
]
},
"execution_count": 7,
@@ -423,7 +447,7 @@
{
"data": {
"text/plain": [
- "RSSValues(total_rss=919.9902719999999, private_rss=699.3838079999999, shared_rss=230.268928)"
+ "RSSValues(total_rss=873.8529279999999, private_rss=638.353408, shared_rss=235.679744)"
]
},
"execution_count": 9,
@@ -444,7 +468,7 @@
{
"data": {
"text/plain": [
- "919.9902719999999"
+ "873.8529279999999"
]
},
"execution_count": 10,
@@ -465,7 +489,7 @@
{
"data": {
"text/plain": [
- "MaxGPURAM(unit='megabytes', system_capacity=16376.0, system=727.0, main=506.0, descendants=0.0, combined=506.0)"
+ "MaxGPURAM(unit='megabytes', system_capacity=16376.0, system=728.0, main=506.0, descendants=0.0, combined=506.0)"
]
},
"execution_count": 11,
@@ -486,7 +510,7 @@
{
"data": {
"text/plain": [
- "ComputeTime(unit='seconds', time=2.684972047805786)"
+ "ComputeTime(unit='seconds', time=2.728560209274292)"
]
},
"execution_count": 12,
@@ -498,6 +522,99 @@
"tracker.resource_usage.compute_time"
]
},
+ {
+ "cell_type": "markdown",
+ "id": "57c1c857-175d-4497-bee8-28c615f31ac4",
+ "metadata": {},
+ "source": [
+ "Below is an example of using a child process. Notice the descendants fields are now non-zero."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "id": "f429ced6-573b-4f0f-ad64-658e9c05242d",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Max RAM:\n",
+ " Unit: gigabytes\n",
+ " System capacity: 67.254\n",
+ " System: 2.388\n",
+ " Main:\n",
+ " Total RSS: 0.849\n",
+ " Private RSS: 0.528\n",
+ " Shared RSS: 0.325\n",
+ " Descendants:\n",
+ " Total RSS: 0.845\n",
+ " Private RSS: 0.734\n",
+ " Shared RSS: 0.112\n",
+ " Combined:\n",
+ " Total RSS: 1.371\n",
+ " Private RSS: 1.05\n",
+ " Shared RSS: 0.325\n",
+ "Max GPU RAM:\n",
+ " Unit: gigabytes\n",
+ " System capacity: 16.376\n",
+ " System: 1.236\n",
+ " Main: 0.506\n",
+ " Descendants: 0.506\n",
+ " Combined: 1.012\n",
+ "CPU utilization:\n",
+ " System core count: 12\n",
+ " Number of expected cores: 2\n",
+ " System:\n",
+ " Max sum percent: 338.0\n",
+ " Max hardware percent: 28.167\n",
+ " Mean sum percent: 183.644\n",
+ " Mean hardware percent: 15.304\n",
+ " Main:\n",
+ " Max sum percent: 101.0\n",
+ " Max hardware percent: 50.5\n",
+ " Mean sum percent: 60.178\n",
+ " Mean hardware percent: 30.089\n",
+ " Descendants:\n",
+ " Max sum percent: 354.1\n",
+ " Max hardware percent: 177.05\n",
+ " Mean sum percent: 109.033\n",
+ " Mean hardware percent: 54.517\n",
+ " Combined:\n",
+ " Max sum percent: 452.2\n",
+ " Max hardware percent: 226.1\n",
+ " Mean sum percent: 169.211\n",
+ " Mean hardware percent: 84.606\n",
+ " Main number of threads: 15\n",
+ " Descendants number of threads: 13\n",
+ " Combined number of threads: 28\n",
+ "GPU utilization:\n",
+ " System GPU count: 1\n",
+ " Number of expected GPUs: 1\n",
+ " GPU percentages:\n",
+ " Max sum percent: 5.0\n",
+ " Max hardware percent: 5.0\n",
+ " Mean sum percent: 0.556\n",
+ " Mean hardware percent: 0.556\n",
+ "Compute time:\n",
+ " Unit: hours\n",
+ " Time: 0.001\n"
+ ]
+ }
+ ],
+ "source": [
+ "import multiprocessing as mp\n",
+ "ctx = mp.get_context(method='spawn')\n",
+ "child_process = ctx.Process(target=example_function)\n",
+ "with gput.Tracker(n_expected_cores=2, sleep_time=0.4) as tracker:\n",
+ " child_process.start()\n",
+ " example_function()\n",
+ " child_process.join()\n",
+ "child_process.close()\n",
+ "print(tracker)"
+ ]
+ },
{
"cell_type": "markdown",
"id": "c2cacaf2-316f-463b-bccd-3a9cdcd89a66",
@@ -508,7 +625,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 14,
"id": "8de6c83f-63b1-4fd3-ae22-a87bd760aad2",
"metadata": {},
"outputs": [
@@ -542,105 +659,1489 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 15,
"id": "e568483c-18bc-4162-b74e-03a4d6ff8b45",
"metadata": {},
"outputs": [],
"source": [
- "tracker = gput.Tracker(resource_usage_file='path/to/my-file.pkl')"
+ "tracker = gput.Tracker(resource_usage_file='path/to/my-file.pkl')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "7abc5c16-0d24-4c73-8e06-8bfa9b101298",
+ "metadata": {},
+ "source": [
+ "While the `Tracker` class automatically detects which brand of GPU is installed (either NVIDIA or AMD), one can explicitly choose the GPU brand with the `gpu_brand` parameter"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "id": "da1a8850-d143-451e-8faf-352f6b5b37c6",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "tracker = gput.Tracker(gpu_brand='nvidia')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "ad908deb-2314-4b1d-bc1d-4ab14ebbcb32",
+ "metadata": {},
+ "source": [
+ "While the `Tracker` by default stores aggregates of the computational resource usage across the timepoints, one can store the individual measured values at every timepoint in a file, either CSV or SQLite format, using the `tracking_file` parameter. **NOTE** for the CSV format, the static data (e.g. RAM system capacity, number of cores in the OS, etc.) is stored on the the first two rows with the headers on the first row followed by the static data on the second row. The headers of the timepoint data is on the third row followed by the timepoint data on the remaining rows. The SQLite file, however, stores the static data and timepoint data in different tables: \"data\" and \"static_data\" respectively."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "fc8b9ce0-3b78-4527-9905-2b1a6564c9b0",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "tracker = gput.Tracker(tracking_file='my-file.csv')\n",
+ "tracker = gput.Tracker(tracking_file='my-file.sqlite')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "5f8f5b0d-2200-4b39-8abf-2dddc03f952f",
+ "metadata": {},
+ "source": [
+ "### Sub-tracking"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "17200926-f0e1-42c4-a8f2-3e6d3734de9a",
+ "metadata": {},
+ "source": [
+ "#### Logging Code Block Timestamps"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "841d90bc-7f79-4d1f-a92c-d339a6403851",
+ "metadata": {},
+ "source": [
+ "While the `Tracker` object by itself can track a block of code, there are some cases where one might want to track one code block and a smaller code block within it or track multiple code blocks at a time without creating several tracking processes simultaneously, especially when tracking a code block that is called within multi-processing or a code block that is called several times. Similarly, one might want to track the resource usage of a particular function whenever it is called. Whether a function or some other specified code block, the `SubTracker` class can determine the computational resources used during the start times and stop times of a given code block. This includes the mean resources used during the times the code block is called, the mean time taken to complete the code block each time it is called, the number of times it is called, etc. Sub-tracking uses the tracking file specified by the `tracking_file` parameter of the `Tracker` object alonside a sub-tracking file which contains the start and stop times of each code block one desires to sub-track. The sub-tracking file can be created in Python using the `SubTracker` class, a context manager around the desired code block. Setting the `overwrite` parameter (default `False`) of the `Tracker` and `SubTracker` to `True` overwrites the `tracking_file` or `sub_tracking_file` respectively if a file of that path already exists. Keep this paramter at `False` to avoid loss of data if it is still needed."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "b3b5e400-1e00-4a6d-b11b-6618efaf2b4a",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "tracker = gput.Tracker(sleep_time=0.5, tracking_file='tracking.csv', overwrite=False)\n",
+ "tracker.start()\n",
+ "# Perform other computation here\n",
+ "for _ in range(5):\n",
+ " with gput.SubTracker(code_block_name='my-code-block', sub_tracking_file='sub-tracking.csv', overwrite=False):\n",
+ " example_function()\n",
+ "# Perform other computation here"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "20a8fac6-26a9-425d-91f1-b40216f59e0a",
+ "metadata": {},
+ "source": [
+ "In the above example, a tracking session is initiated within the context of the `Tracker` object whose tracking file is 'tracking.csv'. Then we have a for loop wherein a function is called 5 times. Other computation might be performed before or after this for loop, but if the computational resource usage of the contents of the for loop is of interest in particular, that code block can be sub-tracked by wrapping it within the context of the `SubTracker` object whose sub-tracking file is 'sub-tracking.csv'. Alternatively, SQLite (.sqlite) files can be used to speed up querying in the case of very long tracking sessions. The name of the code block is 'my-code-block', given to distinguish it from other code blocks being sub-tracked."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "883a4070-caf3-469f-ad73-75a104764f94",
+ "metadata": {},
+ "source": [
+ "If one wants to sub-track all calls to a particular function, the `sub_track` function decorator can be used instead of wrapping the function call with a `SubTracker` context every time it is called:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "c96501c1-75ed-4af9-b93c-9ff9aef607c8",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "@gput.sub_track(code_block_name='my-function', sub_tracking_file='sub-tracking.csv', overwrite=False)\n",
+ "def my_function(*args, **kwargs):\n",
+ " example_function()\n",
+ "\n",
+ "for _ in range(3):\n",
+ " my_function()\n",
+ "tracker.stop()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "0760a8e1-dd2c-4dde-9513-f135c3587e91",
+ "metadata": {},
+ "source": [
+ "When sub-tracking a code block using the `SubTracker` context, the default `code_block_name` is the relative path of the Python file followed by a colon followed by the line number where the `SubTracker` context is initialized. When sub-tracking a function, the default `code_block_name` is the relative path of the Python file followed by a colon followed by the name of the function."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "24bfedad-8388-4305-890c-2b8690940527",
+ "metadata": {},
+ "source": [
+ "#### Analysis"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "92490af9-d033-4ca6-a9d2-32aa6e9901e6",
+ "metadata": {},
+ "source": [
+ "Once a tracking file and at least one sub-tracking file have been created, the results can be analyzed using the `SubTrackingAnalyzer` class, instantiated by passing in the path to the tracking file and the path to the sub-tracking file."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "9d06fd55-0910-438f-8192-f458e6235628",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "analyzer = gput.SubTrackingAnalyzer(tracking_file='tracking.csv', sub_tracking_file='sub-tracking.csv')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "254db857-6d60-4dad-9982-5a19310c7acb",
+ "metadata": {},
+ "source": [
+ "When sub-tracking a code block within a function that's part of multi-processing (i.e. called within one of multiple sub-processes), the sub-tracking file must be unique to that process, which is why the default `sub_tracking_file` is the process ID followed by \".csv\". One way or another, a different sub-tracking file must be created per worker to prevent multiple processes from logging to the same file. The `SubTrackingAnalyzer` has a `combine_sub_tracking_files` method that can combine these multiple sub-tracking files into a single sub-tracking file whose path is specified by the `sub_tracking_file` parameter above. Once a sub-tracking file is created from a single process or combined from multiple, the results can be obtained via the `sub_tracking_results` method."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "c2690ab9-a602-4b32-9920-6929e7bf9de4",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "gpu_tracker.sub_tracker.SubTrackingResults"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "results = analyzer.sub_tracking_results()\n",
+ "type(results)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "7b5dca7b-65f4-4efe-bb01-e88d7ec4f5b9",
+ "metadata": {},
+ "source": [
+ "The `sub_tracking_results` method returns a `SubTrackingResults` object which contains summary statistics of the overall resource usage (all time points in the tracking file) and the per code block resource usage (the timepoints within calls to a code block i.e. the start/stop times) as `DataFrame` or `Series` objects from the `pandas` package."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "89893780-3de4-42cc-b947-c2b1c951f382",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " min | \n",
+ " max | \n",
+ " mean | \n",
+ " std | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | main_ram | \n",
+ " 0.341217 | \n",
+ " 0.920560 | \n",
+ " 0.861921 | \n",
+ " 0.100084 | \n",
+ "
\n",
+ " \n",
+ " | descendants_ram | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | combined_ram | \n",
+ " 0.341217 | \n",
+ " 0.920560 | \n",
+ " 0.861921 | \n",
+ " 0.100084 | \n",
+ "
\n",
+ " \n",
+ " | system_ram | \n",
+ " 4.602618 | \n",
+ " 5.701517 | \n",
+ " 5.281926 | \n",
+ " 0.220270 | \n",
+ "
\n",
+ " \n",
+ " | main_gpu_ram | \n",
+ " 0.000000 | \n",
+ " 0.506000 | \n",
+ " 0.448364 | \n",
+ " 0.151267 | \n",
+ "
\n",
+ " \n",
+ " | descendants_gpu_ram | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | combined_gpu_ram | \n",
+ " 0.000000 | \n",
+ " 0.506000 | \n",
+ " 0.448364 | \n",
+ " 0.151267 | \n",
+ "
\n",
+ " \n",
+ " | system_gpu_ram | \n",
+ " 0.215000 | \n",
+ " 0.727000 | \n",
+ " 0.668909 | \n",
+ " 0.152657 | \n",
+ "
\n",
+ " \n",
+ " | gpu_sum_utilization_percent | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | gpu_hardware_utilization_percent | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | main_n_threads | \n",
+ " 12.000000 | \n",
+ " 15.000000 | \n",
+ " 14.757576 | \n",
+ " 0.791766 | \n",
+ "
\n",
+ " \n",
+ " | descendants_n_threads | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | combined_n_threads | \n",
+ " 12.000000 | \n",
+ " 15.000000 | \n",
+ " 14.757576 | \n",
+ " 0.791766 | \n",
+ "
\n",
+ " \n",
+ " | cpu_system_sum_utilization_percent | \n",
+ " 15.400000 | \n",
+ " 138.400000 | \n",
+ " 121.918182 | \n",
+ " 19.484617 | \n",
+ "
\n",
+ " \n",
+ " | cpu_system_hardware_utilization_percent | \n",
+ " 1.283333 | \n",
+ " 11.533333 | \n",
+ " 10.159848 | \n",
+ " 1.623718 | \n",
+ "
\n",
+ " \n",
+ " | cpu_main_sum_utilization_percent | \n",
+ " 91.400000 | \n",
+ " 103.300000 | \n",
+ " 99.060606 | \n",
+ " 2.571228 | \n",
+ "
\n",
+ " \n",
+ " | cpu_main_hardware_utilization_percent | \n",
+ " 7.616667 | \n",
+ " 8.608333 | \n",
+ " 8.255051 | \n",
+ " 0.214269 | \n",
+ "
\n",
+ " \n",
+ " | cpu_descendants_sum_utilization_percent | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | cpu_descendants_hardware_utilization_percent | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | cpu_combined_sum_utilization_percent | \n",
+ " 91.400000 | \n",
+ " 103.300000 | \n",
+ " 99.060606 | \n",
+ " 2.571228 | \n",
+ "
\n",
+ " \n",
+ " | cpu_combined_hardware_utilization_percent | \n",
+ " 7.616667 | \n",
+ " 8.608333 | \n",
+ " 8.255051 | \n",
+ " 0.214269 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " min max \\\n",
+ "main_ram 0.341217 0.920560 \n",
+ "descendants_ram 0.000000 0.000000 \n",
+ "combined_ram 0.341217 0.920560 \n",
+ "system_ram 4.602618 5.701517 \n",
+ "main_gpu_ram 0.000000 0.506000 \n",
+ "descendants_gpu_ram 0.000000 0.000000 \n",
+ "combined_gpu_ram 0.000000 0.506000 \n",
+ "system_gpu_ram 0.215000 0.727000 \n",
+ "gpu_sum_utilization_percent 0.000000 0.000000 \n",
+ "gpu_hardware_utilization_percent 0.000000 0.000000 \n",
+ "main_n_threads 12.000000 15.000000 \n",
+ "descendants_n_threads 0.000000 0.000000 \n",
+ "combined_n_threads 12.000000 15.000000 \n",
+ "cpu_system_sum_utilization_percent 15.400000 138.400000 \n",
+ "cpu_system_hardware_utilization_percent 1.283333 11.533333 \n",
+ "cpu_main_sum_utilization_percent 91.400000 103.300000 \n",
+ "cpu_main_hardware_utilization_percent 7.616667 8.608333 \n",
+ "cpu_descendants_sum_utilization_percent 0.000000 0.000000 \n",
+ "cpu_descendants_hardware_utilization_percent 0.000000 0.000000 \n",
+ "cpu_combined_sum_utilization_percent 91.400000 103.300000 \n",
+ "cpu_combined_hardware_utilization_percent 7.616667 8.608333 \n",
+ "\n",
+ " mean std \n",
+ "main_ram 0.861921 0.100084 \n",
+ "descendants_ram 0.000000 0.000000 \n",
+ "combined_ram 0.861921 0.100084 \n",
+ "system_ram 5.281926 0.220270 \n",
+ "main_gpu_ram 0.448364 0.151267 \n",
+ "descendants_gpu_ram 0.000000 0.000000 \n",
+ "combined_gpu_ram 0.448364 0.151267 \n",
+ "system_gpu_ram 0.668909 0.152657 \n",
+ "gpu_sum_utilization_percent 0.000000 0.000000 \n",
+ "gpu_hardware_utilization_percent 0.000000 0.000000 \n",
+ "main_n_threads 14.757576 0.791766 \n",
+ "descendants_n_threads 0.000000 0.000000 \n",
+ "combined_n_threads 14.757576 0.791766 \n",
+ "cpu_system_sum_utilization_percent 121.918182 19.484617 \n",
+ "cpu_system_hardware_utilization_percent 10.159848 1.623718 \n",
+ "cpu_main_sum_utilization_percent 99.060606 2.571228 \n",
+ "cpu_main_hardware_utilization_percent 8.255051 0.214269 \n",
+ "cpu_descendants_sum_utilization_percent 0.000000 0.000000 \n",
+ "cpu_descendants_hardware_utilization_percent 0.000000 0.000000 \n",
+ "cpu_combined_sum_utilization_percent 99.060606 2.571228 \n",
+ "cpu_combined_hardware_utilization_percent 8.255051 0.214269 "
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "results.overall"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "4f840359-3ab5-45f2-a5cf-d1c442d7fe44",
+ "metadata": {},
+ "source": [
+ "The `SubTrackingResults` class additionally contains the static data i.e. the information that remains constant throughout the tracking session."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "ba266d13-7317-4eff-8ca9-e547baf890f3",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "ram_unit gigabytes\n",
+ "gpu_ram_unit gigabytes\n",
+ "time_unit hours\n",
+ "ram_system_capacity 67.254166\n",
+ "gpu_ram_system_capacity 16.376\n",
+ "system_core_count 12\n",
+ "n_expected_cores 12\n",
+ "system_gpu_count 1\n",
+ "n_expected_gpus 1\n",
+ "Name: 0, dtype: object"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "results.static_data"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1af42d3a-da9e-4be1-a5ea-808887ecab3d",
+ "metadata": {},
+ "source": [
+ "The `code_block_results` attribute of the `SubTrackingResults` class is a list of `CodeBlockResults` objects, containing the resource usage and compute time summary statistics. In this case, there are two `CodeBlockResults` objects in the list since there were two code blocks sub-tracked in this tracking session."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "7aa9edb7-bf15-4cbf-a55c-5eb4eb950240",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "gpu_tracker.sub_tracker.CodeBlockResults"
+ ]
+ },
+ "execution_count": 8,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "[my_code_block_results, my_function_results] = results.code_block_results\n",
+ "type(my_code_block_results)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "d9226949-f9de-4f88-ac1d-a5bd90a835e2",
+ "metadata": {},
+ "source": [
+ "The `compute_time` attribute of the `CodeBlockResults` class contains summary statistics for the time spent on the code block, where `total` is the total amount of time spent within the code block during the tracking session, `mean` is the average time taken on each call to the code block, etc. The `resource_usage` attribute provides summary statistics for the computational resources used during calls to the code block i.e. within the start/stop times."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "id": "9bb17d2a-7149-4d04-a543-8f3793bae678",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "min 2.630907\n",
+ "max 2.869182\n",
+ "mean 2.685580\n",
+ "std 0.102789\n",
+ "total 13.427902\n",
+ "dtype: float64"
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "my_code_block_results.compute_time"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "id": "6b843a24-9e9f-4566-b447-2067410ba64e",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " min | \n",
+ " max | \n",
+ " mean | \n",
+ " std | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | main_ram | \n",
+ " 0.341217 | \n",
+ " 0.912278 | \n",
+ " 0.846999 | \n",
+ " 0.122948 | \n",
+ "
\n",
+ " \n",
+ " | descendants_ram | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | combined_ram | \n",
+ " 0.341217 | \n",
+ " 0.912278 | \n",
+ " 0.846999 | \n",
+ " 0.122948 | \n",
+ "
\n",
+ " \n",
+ " | system_ram | \n",
+ " 4.602618 | \n",
+ " 5.261357 | \n",
+ " 5.170665 | \n",
+ " 0.147118 | \n",
+ "
\n",
+ " \n",
+ " | main_gpu_ram | \n",
+ " 0.000000 | \n",
+ " 0.506000 | \n",
+ " 0.415429 | \n",
+ " 0.182971 | \n",
+ "
\n",
+ " \n",
+ " | descendants_gpu_ram | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | combined_gpu_ram | \n",
+ " 0.000000 | \n",
+ " 0.506000 | \n",
+ " 0.415429 | \n",
+ " 0.182971 | \n",
+ "
\n",
+ " \n",
+ " | system_gpu_ram | \n",
+ " 0.215000 | \n",
+ " 0.727000 | \n",
+ " 0.635714 | \n",
+ " 0.184676 | \n",
+ "
\n",
+ " \n",
+ " | gpu_sum_utilization_percent | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | gpu_hardware_utilization_percent | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | main_n_threads | \n",
+ " 12.000000 | \n",
+ " 15.000000 | \n",
+ " 14.619048 | \n",
+ " 0.973457 | \n",
+ "
\n",
+ " \n",
+ " | descendants_n_threads | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | combined_n_threads | \n",
+ " 12.000000 | \n",
+ " 15.000000 | \n",
+ " 14.619048 | \n",
+ " 0.973457 | \n",
+ "
\n",
+ " \n",
+ " | cpu_system_sum_utilization_percent | \n",
+ " 15.400000 | \n",
+ " 138.400000 | \n",
+ " 120.142857 | \n",
+ " 24.347907 | \n",
+ "
\n",
+ " \n",
+ " | cpu_system_hardware_utilization_percent | \n",
+ " 1.283333 | \n",
+ " 11.533333 | \n",
+ " 10.011905 | \n",
+ " 2.028992 | \n",
+ "
\n",
+ " \n",
+ " | cpu_main_sum_utilization_percent | \n",
+ " 91.400000 | \n",
+ " 103.300000 | \n",
+ " 98.652381 | \n",
+ " 2.733243 | \n",
+ "
\n",
+ " \n",
+ " | cpu_main_hardware_utilization_percent | \n",
+ " 7.616667 | \n",
+ " 8.608333 | \n",
+ " 8.221032 | \n",
+ " 0.227770 | \n",
+ "
\n",
+ " \n",
+ " | cpu_descendants_sum_utilization_percent | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | cpu_descendants_hardware_utilization_percent | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | cpu_combined_sum_utilization_percent | \n",
+ " 91.400000 | \n",
+ " 103.300000 | \n",
+ " 98.652381 | \n",
+ " 2.733243 | \n",
+ "
\n",
+ " \n",
+ " | cpu_combined_hardware_utilization_percent | \n",
+ " 7.616667 | \n",
+ " 8.608333 | \n",
+ " 8.221032 | \n",
+ " 0.227770 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " min max \\\n",
+ "main_ram 0.341217 0.912278 \n",
+ "descendants_ram 0.000000 0.000000 \n",
+ "combined_ram 0.341217 0.912278 \n",
+ "system_ram 4.602618 5.261357 \n",
+ "main_gpu_ram 0.000000 0.506000 \n",
+ "descendants_gpu_ram 0.000000 0.000000 \n",
+ "combined_gpu_ram 0.000000 0.506000 \n",
+ "system_gpu_ram 0.215000 0.727000 \n",
+ "gpu_sum_utilization_percent 0.000000 0.000000 \n",
+ "gpu_hardware_utilization_percent 0.000000 0.000000 \n",
+ "main_n_threads 12.000000 15.000000 \n",
+ "descendants_n_threads 0.000000 0.000000 \n",
+ "combined_n_threads 12.000000 15.000000 \n",
+ "cpu_system_sum_utilization_percent 15.400000 138.400000 \n",
+ "cpu_system_hardware_utilization_percent 1.283333 11.533333 \n",
+ "cpu_main_sum_utilization_percent 91.400000 103.300000 \n",
+ "cpu_main_hardware_utilization_percent 7.616667 8.608333 \n",
+ "cpu_descendants_sum_utilization_percent 0.000000 0.000000 \n",
+ "cpu_descendants_hardware_utilization_percent 0.000000 0.000000 \n",
+ "cpu_combined_sum_utilization_percent 91.400000 103.300000 \n",
+ "cpu_combined_hardware_utilization_percent 7.616667 8.608333 \n",
+ "\n",
+ " mean std \n",
+ "main_ram 0.846999 0.122948 \n",
+ "descendants_ram 0.000000 0.000000 \n",
+ "combined_ram 0.846999 0.122948 \n",
+ "system_ram 5.170665 0.147118 \n",
+ "main_gpu_ram 0.415429 0.182971 \n",
+ "descendants_gpu_ram 0.000000 0.000000 \n",
+ "combined_gpu_ram 0.415429 0.182971 \n",
+ "system_gpu_ram 0.635714 0.184676 \n",
+ "gpu_sum_utilization_percent 0.000000 0.000000 \n",
+ "gpu_hardware_utilization_percent 0.000000 0.000000 \n",
+ "main_n_threads 14.619048 0.973457 \n",
+ "descendants_n_threads 0.000000 0.000000 \n",
+ "combined_n_threads 14.619048 0.973457 \n",
+ "cpu_system_sum_utilization_percent 120.142857 24.347907 \n",
+ "cpu_system_hardware_utilization_percent 10.011905 2.028992 \n",
+ "cpu_main_sum_utilization_percent 98.652381 2.733243 \n",
+ "cpu_main_hardware_utilization_percent 8.221032 0.227770 \n",
+ "cpu_descendants_sum_utilization_percent 0.000000 0.000000 \n",
+ "cpu_descendants_hardware_utilization_percent 0.000000 0.000000 \n",
+ "cpu_combined_sum_utilization_percent 98.652381 2.733243 \n",
+ "cpu_combined_hardware_utilization_percent 8.221032 0.227770 "
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "my_code_block_results.resource_usage"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1b7149fe-ebac-4575-a203-9a6410371f4c",
+ "metadata": {},
+ "source": [
+ "Additionally, the `CodeBlockResults` class also has attributes for the name of the code block, the number of times it was called during the tracking session, the number of calls that included at least one timepoint, and the total number of timepoints measured within all calls to the code block."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "id": "c6626a74-24a3-4676-a322-41f4514f192c",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "('my-code-block', 5, 5, 21)"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "my_code_block_results.name, my_code_block_results.num_calls, my_code_block_results.num_non_empty_calls, my_code_block_results.num_timepoints"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "b1eb73ed-7b5d-4250-9758-c2d8f5b92223",
+ "metadata": {},
+ "source": [
+ "The analysis results can also be printed in their entirety. Alternatively, the `to_json` method can provide this comprehensive information in JSON format."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "1cfa4d02-9812-4ad5-b6d9-dc5f1f80cc03",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Overall:\n",
+ "\t min max mean std\n",
+ "\tmain_ram 0.341860 0.944374 0.856037 0.125014\n",
+ "\tdescendants_ram 0.000000 0.000000 0.000000 0.000000\n",
+ "\tcombined_ram 0.341860 0.944374 0.856037 0.125014\n",
+ "\tsystem_ram 4.859711 5.553644 5.253445 0.134081\n",
+ "\tmain_gpu_ram 0.000000 0.506000 0.429920 0.170432\n",
+ "\tdescendants_gpu_ram 0.000000 0.000000 0.000000 0.000000\n",
+ "\tcombined_gpu_ram 0.000000 0.506000 0.429920 0.170432\n",
+ "\tsystem_gpu_ram 0.215000 0.727000 0.650320 0.172010\n",
+ "\tgpu_sum_utilization_percent 0.000000 3.000000 0.120000 0.600000\n",
+ "\tgpu_hardware_utilization_percent 0.000000 3.000000 0.120000 0.600000\n",
+ "\tmain_n_threads 12.000000 15.000000 14.720000 0.842615\n",
+ "\tdescendants_n_threads 0.000000 0.000000 0.000000 0.000000\n",
+ "\tcombined_n_threads 12.000000 15.000000 14.720000 0.842615\n",
+ "\tcpu_system_sum_utilization_percent 11.900000 133.400000 119.212000 22.741909\n",
+ "\tcpu_system_hardware_utilization_percent 0.991667 11.116667 9.934333 1.895159\n",
+ "\tcpu_main_sum_utilization_percent 78.000000 103.200000 96.924000 6.390767\n",
+ "\tcpu_main_hardware_utilization_percent 6.500000 8.600000 8.077000 0.532564\n",
+ "\tcpu_descendants_sum_utilization_percent 0.000000 0.000000 0.000000 0.000000\n",
+ "\tcpu_descendants_hardware_utilization_percent 0.000000 0.000000 0.000000 0.000000\n",
+ "\tcpu_combined_sum_utilization_percent 78.000000 103.200000 96.924000 6.390767\n",
+ "\tcpu_combined_hardware_utilization_percent 6.500000 8.600000 8.077000 0.532564\n",
+ "Static Data:\n",
+ "\t ram_unit gpu_ram_unit time_unit ram_system_capacity gpu_ram_system_capacity system_core_count n_expected_cores system_gpu_count n_expected_gpus\n",
+ "\t gigabytes gigabytes hours 67.254166 16.376 12 12 1 1\n",
+ "Code Block Results:\n",
+ "\tName: my-code-block\n",
+ "\tNum Timepoints: 12\n",
+ "\tNum Calls: 3\n",
+ "\tNum Non Empty Calls: 3\n",
+ "\tCompute Time:\n",
+ "\t\t min max mean std total\n",
+ "\t\t 2.580433 2.789909 2.651185 0.120147 7.953554\n",
+ "\tResource Usage:\n",
+ "\t\t min max mean std\n",
+ "\t\tmain_ram 0.341860 0.936559 0.808736 0.167663\n",
+ "\t\tdescendants_ram 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tcombined_ram 0.341860 0.936559 0.808736 0.167663\n",
+ "\t\tsystem_ram 4.859711 5.553644 5.231854 0.191567\n",
+ "\t\tmain_gpu_ram 0.000000 0.506000 0.363500 0.225892\n",
+ "\t\tdescendants_gpu_ram 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tcombined_gpu_ram 0.000000 0.506000 0.363500 0.225892\n",
+ "\t\tsystem_gpu_ram 0.215000 0.727000 0.583250 0.228088\n",
+ "\t\tgpu_sum_utilization_percent 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tgpu_hardware_utilization_percent 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tmain_n_threads 12.000000 15.000000 14.416667 1.164500\n",
+ "\t\tdescendants_n_threads 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tcombined_n_threads 12.000000 15.000000 14.416667 1.164500\n",
+ "\t\tcpu_system_sum_utilization_percent 11.900000 130.800000 113.641667 32.352363\n",
+ "\t\tcpu_system_hardware_utilization_percent 0.991667 10.900000 9.470139 2.696030\n",
+ "\t\tcpu_main_sum_utilization_percent 79.600000 103.100000 96.583333 6.726587\n",
+ "\t\tcpu_main_hardware_utilization_percent 6.633333 8.591667 8.048611 0.560549\n",
+ "\t\tcpu_descendants_sum_utilization_percent 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tcpu_descendants_hardware_utilization_percent 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tcpu_combined_sum_utilization_percent 79.600000 103.100000 96.583333 6.726587\n",
+ "\t\tcpu_combined_hardware_utilization_percent 6.633333 8.591667 8.048611 0.560549\n",
+ "\n",
+ "\tName: my-function\n",
+ "\tNum Timepoints: 12\n",
+ "\tNum Calls: 3\n",
+ "\tNum Non Empty Calls: 3\n",
+ "\tCompute Time:\n",
+ "\t\t min max mean std total\n",
+ "\t\t 2.538011 2.577679 2.553176 0.021419 7.659528\n",
+ "\tResource Usage:\n",
+ "\t\t min max mean std\n",
+ "\t\tmain_ram 0.864592 0.944374 0.896998 0.034505\n",
+ "\t\tdescendants_ram 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tcombined_ram 0.864592 0.944374 0.896998 0.034505\n",
+ "\t\tsystem_ram 5.203415 5.315219 5.271566 0.038751\n",
+ "\t\tmain_gpu_ram 0.314000 0.506000 0.490000 0.055426\n",
+ "\t\tdescendants_gpu_ram 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tcombined_gpu_ram 0.314000 0.506000 0.490000 0.055426\n",
+ "\t\tsystem_gpu_ram 0.535000 0.727000 0.711000 0.055426\n",
+ "\t\tgpu_sum_utilization_percent 0.000000 3.000000 0.250000 0.866025\n",
+ "\t\tgpu_hardware_utilization_percent 0.000000 3.000000 0.250000 0.866025\n",
+ "\t\tmain_n_threads 15.000000 15.000000 15.000000 0.000000\n",
+ "\t\tdescendants_n_threads 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tcombined_n_threads 15.000000 15.000000 15.000000 0.000000\n",
+ "\t\tcpu_system_sum_utilization_percent 120.300000 133.400000 124.566667 4.001439\n",
+ "\t\tcpu_system_hardware_utilization_percent 10.025000 11.116667 10.380556 0.333453\n",
+ "\t\tcpu_main_sum_utilization_percent 94.700000 103.200000 98.841667 2.677332\n",
+ "\t\tcpu_main_hardware_utilization_percent 7.891667 8.600000 8.236806 0.223111\n",
+ "\t\tcpu_descendants_sum_utilization_percent 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tcpu_descendants_hardware_utilization_percent 0.000000 0.000000 0.000000 0.000000\n",
+ "\t\tcpu_combined_sum_utilization_percent 94.700000 103.200000 98.841667 2.677332\n",
+ "\t\tcpu_combined_hardware_utilization_percent 7.891667 8.600000 8.236806 0.223111\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(results)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "91d9aa35-21b8-408e-a602-a542b68802cf",
+ "metadata": {},
+ "source": [
+ "#### Comparison"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "8c94f65e-e48d-4c7e-bdb2-2b6081651674",
+ "metadata": {},
+ "source": [
+ "The `TrackingComparison` class allows for comparing the resource usage of multiple tracking sessions, both the overall usage of the sessions and any code blocks that were sub-tracked. This is helpful if one wants to see how changes to the process might impact the computational efficiency of it, such as changes to implementation, input data, etc. To do this, the `TrackingComparison` takes a mapping of the given name of a tracking session to the file path where a `SubTrackingResults` object is stored in pickle format. Say we had two tracking sessions and we wanted to compare them. First, we store the `results` of the first tracking session in a pickle file. If we'd like to re-use the same names for the `tracking_file` and `sub_tracking_file` in the second tracking session, we can safely set the `overwrite` argument to `True` since their data has been saved in 'results.pkl'."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "f32eeb3f-7dc1-4e8c-99b0-617e057a8b50",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import pickle as pkl\n",
+ "import os\n",
+ "\n",
+ "with open('results.pkl', 'wb') as file:\n",
+ " pkl.dump(results, file)\n",
+ "os._exit(0)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "e6fe42cc-e069-456d-b084-e02162e3adca",
+ "metadata": {},
+ "source": [
+ "Once we have the results of the first tracking session saved, we can start a new tracking session in another run of the program that we are profiling. Say we made some code changes and we want to compare the two implementations, we can populate a new `tracking_file` and `sub_tracking_file` with data from the new tracking session."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "183ea8c3-79ad-4d73-bef8-51dcf74909a3",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import gpu_tracker as gput\n",
+ "from example_module import example_function\n",
+ "import pickle as pkl\n",
+ "\n",
+ "@gput.sub_track(code_block_name='my-function', sub_tracking_file='sub-tracking.csv', overwrite=True)\n",
+ "def my_function(*args, **kwargs):\n",
+ " example_function()\n",
+ "\n",
+ "with gput.Tracker(sleep_time=0.5, tracking_file='tracking.csv', overwrite=True):\n",
+ " for _ in range(3):\n",
+ " with gput.SubTracker(code_block_name='my-code-block', sub_tracking_file='sub-tracking.csv', overwrite=True):\n",
+ " example_function()\n",
+ " my_function()\n",
+ "results2 = gput.SubTrackingAnalyzer(tracking_file='tracking.csv', sub_tracking_file='sub-tracking.csv').sub_tracking_results()\n",
+ "with open('results2.pkl', 'wb') as file:\n",
+ " pkl.dump(results2, file)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "f4df28d0-f020-449d-bdcc-f229ac88c986",
+ "metadata": {},
+ "source": [
+ "The first tracking session stored its results in 'results.pkl' while the second tracking session stored its results in 'results2.pkl'. Say we decided to call the first session 'A' and the second session 'B'. The `TrackingComparison` object would be initialized like so:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "39663fc5-c4b3-4099-b418-be5d57afa38a",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "comparison = gput.TrackingComparison(file_path_map={'A': 'results.pkl', 'B': 'results2.pkl'})"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "62c8d695-622d-475b-b264-1e4f549fce6f",
+ "metadata": {},
+ "source": [
+ "Once the `TrackingComparison` is created, its compare method generates the `ComparisonResults` object detailing the computational resource usage measured in one tracking session to that of the other tracking sessions. The `statistic` parameter determines which summary statistic of the measurements to compare, defaulting to 'mean'. In this example, we will compare the maximum measurements by setting `statistic` to 'max'."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "6034e4c2-0837-4dd6-b305-5f0f97abdc55",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "gpu_tracker.sub_tracker.ComparisonResults"
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "results = comparison.compare(statistic='max')\n",
+ "type(results)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "cc24e155-5852-40ce-8dd5-7df088785153",
+ "metadata": {},
+ "source": [
+ "The `overall_resource_usage` attribute of the `ComparisonResults` class is a dictionary mapping each measurement to a `Series` comparing that measurement across all timepoints in one tracking session to another."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "id": "feb75a78-c84b-41e5-a266-2668ced824f3",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "dict_keys(['main_ram', 'descendants_ram', 'combined_ram', 'system_ram', 'main_gpu_ram', 'descendants_gpu_ram', 'combined_gpu_ram', 'system_gpu_ram', 'gpu_sum_utilization_percent', 'gpu_hardware_utilization_percent', 'main_n_threads', 'descendants_n_threads', 'combined_n_threads', 'cpu_system_sum_utilization_percent', 'cpu_system_hardware_utilization_percent', 'cpu_main_sum_utilization_percent', 'cpu_main_hardware_utilization_percent', 'cpu_descendants_sum_utilization_percent', 'cpu_descendants_hardware_utilization_percent', 'cpu_combined_sum_utilization_percent', 'cpu_combined_hardware_utilization_percent'])"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "results.overall_resource_usage.keys()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "ae8426f1-6cad-4180-80a8-f63048226609",
+ "metadata": {},
+ "source": [
+ "For example, we can compare the overall maximum 'main_ram' of tracking session 'A' to tracking session 'B'."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "id": "0a76fa26-a041-4e44-b5cd-0065066818ba",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "A 0.920560\n",
+ "B 0.944374\n",
+ "dtype: float64"
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "results.overall_resource_usage['main_ram']"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "4f0daecd-7560-4d8d-8677-da47119fba96",
+ "metadata": {},
+ "source": [
+ "The `code_block_resource_usage` attribute is a dictionary that compares the same resource usage but for each code block rather than overall."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "id": "e4d6ee1f-cfcb-47bb-9503-dddf757ed7cc",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "dict_keys(['main_ram', 'descendants_ram', 'combined_ram', 'system_ram', 'main_gpu_ram', 'descendants_gpu_ram', 'combined_gpu_ram', 'system_gpu_ram', 'gpu_sum_utilization_percent', 'gpu_hardware_utilization_percent', 'main_n_threads', 'descendants_n_threads', 'combined_n_threads', 'cpu_system_sum_utilization_percent', 'cpu_system_hardware_utilization_percent', 'cpu_main_sum_utilization_percent', 'cpu_main_hardware_utilization_percent', 'cpu_descendants_sum_utilization_percent', 'cpu_descendants_hardware_utilization_percent', 'cpu_combined_sum_utilization_percent', 'cpu_combined_hardware_utilization_percent'])"
+ ]
+ },
+ "execution_count": 17,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "results.code_block_resource_usage.keys()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "f9bce9d8-4c21-4257-9481-36d8aed6c15b",
+ "metadata": {},
+ "source": [
+ "Each measurement is a dictionary mapping each code block name to the resources used across tracking sessions in that code block."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "id": "57e7a315-af09-4ded-adfb-90a49ae2ef52",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "dict_keys(['my-code-block', 'my-function'])"
+ ]
+ },
+ "execution_count": 18,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "results.code_block_resource_usage['main_ram'].keys()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "4a3488dd-47ec-4be8-a30b-986dc4059a7c",
+ "metadata": {},
+ "source": [
+ "For example, the maximum 'main_ram' used by 'my-code-block' in tracking session 'A' can be compared to that of tracking session 'B'."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "id": "742c8755-ea9c-43b8-b10e-73a97d19b761",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "A 0.912278\n",
+ "B 0.936559\n",
+ "dtype: float64"
+ ]
+ },
+ "execution_count": 19,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "results.code_block_resource_usage['main_ram']['my-code-block']"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "bba31658-87b8-4708-a225-fdb44ca602c9",
+ "metadata": {},
+ "source": [
+ "Finally the `code_block_compute_time` attribute is a dictionary that compares the compute time summary statistics for each code block and for each tracking session."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "id": "4247891a-e0a9-46f1-8ca1-4ca28d13679b",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "dict_keys(['my-code-block', 'my-function'])"
+ ]
+ },
+ "execution_count": 23,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "results.code_block_compute_time.keys()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "b8aba2e7-c49a-444d-b90d-c1488ad92071",
+ "metadata": {},
+ "source": [
+ "For example, we can compare the maximum compute time of 'my-code-block' in tracking session 'A' to that of tracking session 'B'."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "id": "355f6538-969d-412c-9e88-752f68f3c60d",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "B 2.789909\n",
+ "A 2.869182\n",
+ "dtype: float64"
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "results.code_block_compute_time['my-code-block']"
]
},
{
"cell_type": "markdown",
- "id": "57c1c857-175d-4497-bee8-28c615f31ac4",
+ "id": "308d0ff0-116c-48fb-b399-c7f000c69735",
"metadata": {},
"source": [
- "Below is an example of using a child process. Notice the descendants fields are now non-zero."
+ "The comparison results can also be printed in their entirety. Alternatively, the `to_json` method can provide this comprehensive information in JSON format."
]
},
{
"cell_type": "code",
- "execution_count": 15,
- "id": "f429ced6-573b-4f0f-ad64-658e9c05242d",
+ "execution_count": 7,
+ "id": "a05307bd-ca33-42d9-a9b4-ed4643d303e5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Max RAM:\n",
- " Unit: gigabytes\n",
- " System capacity: 67.254\n",
- " System: 3.033\n",
- " Main:\n",
- " Total RSS: 0.865\n",
- " Private RSS: 0.55\n",
- " Shared RSS: 0.32\n",
- " Descendants:\n",
- " Total RSS: 0.854\n",
- " Private RSS: 0.737\n",
- " Shared RSS: 0.118\n",
- " Combined:\n",
- " Total RSS: 1.437\n",
- " Private RSS: 1.125\n",
- " Shared RSS: 0.32\n",
- "Max GPU RAM:\n",
- " Unit: gigabytes\n",
- " System capacity: 16.376\n",
- " System: 1.235\n",
- " Main: 0.506\n",
- " Descendants: 0.506\n",
- " Combined: 1.012\n",
- "CPU utilization:\n",
- " System core count: 12\n",
- " Number of expected cores: 2\n",
- " System:\n",
- " Max sum percent: 456.5\n",
- " Max hardware percent: 38.042\n",
- " Mean sum percent: 216.675\n",
- " Mean hardware percent: 18.056\n",
- " Main:\n",
- " Max sum percent: 102.6\n",
- " Max hardware percent: 51.3\n",
- " Mean sum percent: 66.65\n",
- " Mean hardware percent: 33.325\n",
- " Descendants:\n",
- " Max sum percent: 175.8\n",
- " Max hardware percent: 87.9\n",
- " Mean sum percent: 105.392\n",
- " Mean hardware percent: 52.696\n",
- " Combined:\n",
- " Max sum percent: 278.4\n",
- " Max hardware percent: 139.2\n",
- " Mean sum percent: 172.042\n",
- " Mean hardware percent: 86.021\n",
- " Main number of threads: 15\n",
- " Descendants number of threads: 13\n",
- " Combined number of threads: 28\n",
- "GPU utilization:\n",
- " System GPU count: 1\n",
- " Number of expected GPUs: 1\n",
- " GPU percentages:\n",
- " Max sum percent: 8.0\n",
- " Max hardware percent: 8.0\n",
- " Mean sum percent: 1.333\n",
- " Mean hardware percent: 1.333\n",
- "Compute time:\n",
- " Unit: hours\n",
- " Time: 0.001\n"
+ "Overall Resource Usage:\n",
+ "\tMain Ram:\n",
+ "\t\t A B\n",
+ "\t\t 0.92056 0.944374\n",
+ "\tDescendants Ram:\n",
+ "\t\t A B\n",
+ "\t\t 0.0 0.0\n",
+ "\tCombined Ram:\n",
+ "\t\t A B\n",
+ "\t\t 0.92056 0.944374\n",
+ "\tSystem Ram:\n",
+ "\t\t B A\n",
+ "\t\t 5.553644 5.701517\n",
+ "\tMain Gpu Ram:\n",
+ "\t\t A B\n",
+ "\t\t 0.506 0.506\n",
+ "\tDescendants Gpu Ram:\n",
+ "\t\t A B\n",
+ "\t\t 0.0 0.0\n",
+ "\tCombined Gpu Ram:\n",
+ "\t\t A B\n",
+ "\t\t 0.506 0.506\n",
+ "\tSystem Gpu Ram:\n",
+ "\t\t A B\n",
+ "\t\t 0.727 0.727\n",
+ "\tGpu Sum Utilization Percent:\n",
+ "\t\t A B\n",
+ "\t\t 0.0 3.0\n",
+ "\tGpu Hardware Utilization Percent:\n",
+ "\t\t A B\n",
+ "\t\t 0.0 3.0\n",
+ "\tMain N Threads:\n",
+ "\t\t A B\n",
+ "\t\t 15.0 15.0\n",
+ "\tDescendants N Threads:\n",
+ "\t\t A B\n",
+ "\t\t 0.0 0.0\n",
+ "\tCombined N Threads:\n",
+ "\t\t A B\n",
+ "\t\t 15.0 15.0\n",
+ "\tCpu System Sum Utilization Percent:\n",
+ "\t\t B A\n",
+ "\t\t 133.4 138.4\n",
+ "\tCpu System Hardware Utilization Percent:\n",
+ "\t\t B A\n",
+ "\t\t 11.116667 11.533333\n",
+ "\tCpu Main Sum Utilization Percent:\n",
+ "\t\t B A\n",
+ "\t\t 103.2 103.3\n",
+ "\tCpu Main Hardware Utilization Percent:\n",
+ "\t\t B A\n",
+ "\t\t 8.6 8.608333\n",
+ "\tCpu Descendants Sum Utilization Percent:\n",
+ "\t\t A B\n",
+ "\t\t 0.0 0.0\n",
+ "\tCpu Descendants Hardware Utilization Percent:\n",
+ "\t\t A B\n",
+ "\t\t 0.0 0.0\n",
+ "\tCpu Combined Sum Utilization Percent:\n",
+ "\t\t B A\n",
+ "\t\t 103.2 103.3\n",
+ "\tCpu Combined Hardware Utilization Percent:\n",
+ "\t\t B A\n",
+ "\t\t 8.6 8.608333\n",
+ "Code Block Resource Usage:\n",
+ "\tMain Ram:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.912278 0.936559\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.92056 0.944374\n",
+ "\tDescendants Ram:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\tCombined Ram:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.912278 0.936559\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.92056 0.944374\n",
+ "\tSystem Ram:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 5.261357 5.553644\n",
+ "\t\tmy-function:\n",
+ "\t\t\t B A\n",
+ "\t\t\t 5.315219 5.701517\n",
+ "\tMain Gpu Ram:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.506 0.506\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.506 0.506\n",
+ "\tDescendants Gpu Ram:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\tCombined Gpu Ram:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.506 0.506\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.506 0.506\n",
+ "\tSystem Gpu Ram:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.727 0.727\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.727 0.727\n",
+ "\tGpu Sum Utilization Percent:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 3.0\n",
+ "\tGpu Hardware Utilization Percent:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 3.0\n",
+ "\tMain N Threads:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 15.0 15.0\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 15.0 15.0\n",
+ "\tDescendants N Threads:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\tCombined N Threads:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 15.0 15.0\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 15.0 15.0\n",
+ "\tCpu System Sum Utilization Percent:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t B A\n",
+ "\t\t\t 130.8 138.4\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 131.1 133.4\n",
+ "\tCpu System Hardware Utilization Percent:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t B A\n",
+ "\t\t\t 10.9 11.533333\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 10.925 11.116667\n",
+ "\tCpu Main Sum Utilization Percent:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t B A\n",
+ "\t\t\t 103.1 103.3\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 102.1 103.2\n",
+ "\tCpu Main Hardware Utilization Percent:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t B A\n",
+ "\t\t\t 8.591667 8.608333\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 8.508333 8.6\n",
+ "\tCpu Descendants Sum Utilization Percent:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\tCpu Descendants Hardware Utilization Percent:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 0.0 0.0\n",
+ "\tCpu Combined Sum Utilization Percent:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t B A\n",
+ "\t\t\t 103.1 103.3\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 102.1 103.2\n",
+ "\tCpu Combined Hardware Utilization Percent:\n",
+ "\t\tmy-code-block:\n",
+ "\t\t\t B A\n",
+ "\t\t\t 8.591667 8.608333\n",
+ "\t\tmy-function:\n",
+ "\t\t\t A B\n",
+ "\t\t\t 8.508333 8.6\n",
+ "Code Block Compute Time:\n",
+ "\tmy-code-block:\n",
+ "\t\t B A\n",
+ "\t\t 2.789909 2.869182\n",
+ "\tmy-function:\n",
+ "\t\t A B\n",
+ "\t\t 2.570437 2.577679\n",
+ "\n"
]
}
],
"source": [
- "import multiprocessing as mp\n",
- "ctx = mp.get_context(method='spawn')\n",
- "child_process = ctx.Process(target=example_function)\n",
- "with gput.Tracker(n_expected_cores=2, sleep_time=0.2) as tracker:\n",
- " child_process.start()\n",
- " example_function()\n",
- " child_process.join()\n",
- "child_process.close()\n",
- "print(tracker)"
+ "print(results)"
]
},
{
@@ -651,6 +2152,22 @@
"## CLI"
]
},
+ {
+ "cell_type": "markdown",
+ "id": "5c7393bd-e3d3-4247-af95-4cdf66b43226",
+ "metadata": {},
+ "source": [
+ "### Tracking"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "99599c6a-ae1e-4e5f-9513-09ee33cb0a4d",
+ "metadata": {},
+ "source": [
+ "#### Basics"
+ ]
+ },
{
"cell_type": "markdown",
"id": "54a3a61b-81cf-4a65-85af-7ba15a111970",
@@ -661,7 +2178,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 26,
"id": "f7deae10-a16b-4a38-acc6-c354911200ab",
"metadata": {},
"outputs": [
@@ -674,21 +2191,37 @@
"Usage:\n",
" gpu-tracker -h | --help\n",
" gpu-tracker -v | --version\n",
- " gpu-tracker --execute= [--output=