halib 0.1.60__tar.gz → 0.1.61__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. {halib-0.1.60 → halib-0.1.61}/PKG-INFO +3 -2
  2. {halib-0.1.60 → halib-0.1.61}/README.md +2 -1
  3. halib-0.1.61/halib/utils/gpu_mon.py +58 -0
  4. {halib-0.1.60 → halib-0.1.61}/halib.egg-info/PKG-INFO +3 -2
  5. {halib-0.1.60 → halib-0.1.61}/halib.egg-info/SOURCES.txt +1 -0
  6. {halib-0.1.60 → halib-0.1.61}/setup.py +1 -1
  7. {halib-0.1.60 → halib-0.1.61}/.gitignore +0 -0
  8. {halib-0.1.60 → halib-0.1.61}/GDriveFolder.txt +0 -0
  9. {halib-0.1.60 → halib-0.1.61}/LICENSE.txt +0 -0
  10. {halib-0.1.60 → halib-0.1.61}/MANIFEST.in +0 -0
  11. {halib-0.1.60 → halib-0.1.61}/guide_publish_pip.pdf +0 -0
  12. {halib-0.1.60 → halib-0.1.61}/halib/__init__.py +0 -0
  13. {halib-0.1.60 → halib-0.1.61}/halib/common.py +0 -0
  14. {halib-0.1.60 → halib-0.1.61}/halib/cuda.py +0 -0
  15. {halib-0.1.60 → halib-0.1.61}/halib/filetype/__init__.py +0 -0
  16. {halib-0.1.60 → halib-0.1.61}/halib/filetype/csvfile.py +0 -0
  17. {halib-0.1.60 → halib-0.1.61}/halib/filetype/jsonfile.py +0 -0
  18. {halib-0.1.60 → halib-0.1.61}/halib/filetype/textfile.py +0 -0
  19. {halib-0.1.60 → halib-0.1.61}/halib/filetype/videofile.py +0 -0
  20. {halib-0.1.60 → halib-0.1.61}/halib/filetype/yamlfile.py +0 -0
  21. {halib-0.1.60 → halib-0.1.61}/halib/online/__init__.py +0 -0
  22. {halib-0.1.60 → halib-0.1.61}/halib/online/gdrive.py +0 -0
  23. {halib-0.1.60 → halib-0.1.61}/halib/online/gdrive_mkdir.py +0 -0
  24. {halib-0.1.60 → halib-0.1.61}/halib/online/gdrive_test.py +0 -0
  25. {halib-0.1.60 → halib-0.1.61}/halib/online/projectmake.py +0 -0
  26. {halib-0.1.60 → halib-0.1.61}/halib/research/__init__.py +0 -0
  27. {halib-0.1.60 → halib-0.1.61}/halib/research/dataset.py +0 -0
  28. {halib-0.1.60 → halib-0.1.61}/halib/research/perfcalc.py +0 -0
  29. {halib-0.1.60 → halib-0.1.61}/halib/research/perftb.py +0 -0
  30. {halib-0.1.60 → halib-0.1.61}/halib/research/plot.py +0 -0
  31. {halib-0.1.60 → halib-0.1.61}/halib/research/torchloader.py +0 -0
  32. {halib-0.1.60 → halib-0.1.61}/halib/research/wandb_op.py +0 -0
  33. {halib-0.1.60 → halib-0.1.61}/halib/rich_color.py +0 -0
  34. {halib-0.1.60 → halib-0.1.61}/halib/system/__init__.py +0 -0
  35. {halib-0.1.60 → halib-0.1.61}/halib/system/cmd.py +0 -0
  36. {halib-0.1.60 → halib-0.1.61}/halib/system/filesys.py +0 -0
  37. {halib-0.1.60 → halib-0.1.61}/halib/utils/__init__.py +0 -0
  38. {halib-0.1.60 → halib-0.1.61}/halib/utils/dataclass_util.py +0 -0
  39. {halib-0.1.60 → halib-0.1.61}/halib/utils/dict_op.py +0 -0
  40. {halib-0.1.60 → halib-0.1.61}/halib/utils/listop.py +0 -0
  41. {halib-0.1.60 → halib-0.1.61}/halib/utils/tele_noti.py +0 -0
  42. {halib-0.1.60 → halib-0.1.61}/halib/utils/video.py +0 -0
  43. {halib-0.1.60 → halib-0.1.61}/halib.egg-info/dependency_links.txt +0 -0
  44. {halib-0.1.60 → halib-0.1.61}/halib.egg-info/requires.txt +0 -0
  45. {halib-0.1.60 → halib-0.1.61}/halib.egg-info/top_level.txt +0 -0
  46. {halib-0.1.60 → halib-0.1.61}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: halib
3
- Version: 0.1.60
3
+ Version: 0.1.61
4
4
  Summary: Small library for common tasks
5
5
  Author: Hoang Van Ha
6
6
  Author-email: hoangvanhauit@gmail.com
@@ -15,9 +15,10 @@ License-File: LICENSE.txt
15
15
 
16
16
  Helper package for coding and automation
17
17
 
18
- **Version 0.1.60**
18
+ **Version 0.1.61**
19
19
 
20
20
  + add `util/video`: add `VideoUtils` class to handle common video-related tasks
21
+ + add `util/gpu_mon`: add `GPUMonitor` class to monitor GPU usage and performance
21
22
 
22
23
  **Version 0.1.59**
23
24
 
@@ -1,8 +1,9 @@
1
1
  Helper package for coding and automation
2
2
 
3
- **Version 0.1.60**
3
+ **Version 0.1.61**
4
4
 
5
5
  + add `util/video`: add `VideoUtils` class to handle common video-related tasks
6
+ + add `util/gpu_mon`: add `GPUMonitor` class to monitor GPU usage and performance
6
7
 
7
8
  **Version 0.1.59**
8
9
 
@@ -0,0 +1,58 @@
1
+ # install `pynvml_utils` package first
2
+ # see this repo: https://github.com/gpuopenanalytics/pynvml
3
+ from pynvml_utils import nvidia_smi
4
+ import time
5
+ import threading
6
+ from rich.pretty import pprint
7
+
8
+ class GPUMonitor:
9
+ def __init__(self, gpu_index=0, interval=0.01):
10
+ self.nvsmi = nvidia_smi.getInstance()
11
+ self.gpu_index = gpu_index
12
+ self.interval = interval
13
+ self.gpu_stats = []
14
+ self._running = False
15
+ self._thread = None
16
+
17
+ def _monitor(self):
18
+ while self._running:
19
+ stats = self.nvsmi.DeviceQuery("power.draw, memory.used")["gpu"][
20
+ self.gpu_index
21
+ ]
22
+ # pprint(stats)
23
+ self.gpu_stats.append(
24
+ {
25
+ "power": stats["power_readings"]["power_draw"],
26
+ "power_unit": stats["power_readings"]["unit"],
27
+ "memory": stats["fb_memory_usage"]["used"],
28
+ "memory_unit": stats["fb_memory_usage"]["unit"],
29
+ }
30
+ )
31
+ time.sleep(self.interval)
32
+
33
+ def start(self):
34
+ if not self._running:
35
+ self._running = True
36
+ # clear previous stats
37
+ self.gpu_stats.clear()
38
+ self._thread = threading.Thread(target=self._monitor)
39
+ self._thread.start()
40
+
41
+ def stop(self):
42
+ if self._running:
43
+ self._running = False
44
+ self._thread.join()
45
+ # clear the thread reference
46
+ self._thread = None
47
+
48
+ def get_stats(self):
49
+ ## return self.gpu_stats
50
+ assert self._running is False, "GPU monitor is still running. Stop it first."
51
+
52
+ powers = [s["power"] for s in self.gpu_stats if s["power"] is not None]
53
+ memories = [s["memory"] for s in self.gpu_stats if s["memory"] is not None]
54
+ avg_power = sum(powers) / len(powers) if powers else 0
55
+ max_memory = max(memories) if memories else 0
56
+ # power_unit = self.gpu_stats[0]["power_unit"] if self.gpu_stats else "W"
57
+ # memory_unit = self.gpu_stats[0]["memory_unit"] if self.gpu_stats else "MiB"
58
+ return {"gpu_avg_power": avg_power, "gpu_avg_max_memory": max_memory}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: halib
3
- Version: 0.1.60
3
+ Version: 0.1.61
4
4
  Summary: Small library for common tasks
5
5
  Author: Hoang Van Ha
6
6
  Author-email: hoangvanhauit@gmail.com
@@ -15,9 +15,10 @@ License-File: LICENSE.txt
15
15
 
16
16
  Helper package for coding and automation
17
17
 
18
- **Version 0.1.60**
18
+ **Version 0.1.61**
19
19
 
20
20
  + add `util/video`: add `VideoUtils` class to handle common video-related tasks
21
+ + add `util/gpu_mon`: add `GPUMonitor` class to monitor GPU usage and performance
21
22
 
22
23
  **Version 0.1.59**
23
24
 
@@ -38,6 +38,7 @@ halib/system/filesys.py
38
38
  halib/utils/__init__.py
39
39
  halib/utils/dataclass_util.py
40
40
  halib/utils/dict_op.py
41
+ halib/utils/gpu_mon.py
41
42
  halib/utils/listop.py
42
43
  halib/utils/tele_noti.py
43
44
  halib/utils/video.py
@@ -8,7 +8,7 @@ with open("requirements.txt") as f:
8
8
 
9
9
  setuptools.setup(
10
10
  name="halib",
11
- version="0.1.60",
11
+ version="0.1.61",
12
12
  author="Hoang Van Ha",
13
13
  author_email="hoangvanhauit@gmail.com",
14
14
  description="Small library for common tasks",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes