skytnt commited on
Commit
8c8890a
ยท
1 Parent(s): 3d5d151

add system_monitor to debug

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import json
2
  import os
 
 
3
  import librosa
4
  import numpy as np
5
  import torch
@@ -73,6 +75,45 @@ def create_vc_fn(model, hps, speaker_ids):
73
  return vc_fn
74
 
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  css = """
77
  #advanced-btn {
78
  color: white;
@@ -92,6 +133,7 @@ css = """
92
  """
93
 
94
  if __name__ == '__main__':
 
95
  models = []
96
  with open("saved_model/names.json", "r", encoding="utf-8") as f:
97
  models_names = json.load(f)
 
1
  import json
2
  import os
3
+ import psutil
4
+ from threading import Timer
5
  import librosa
6
  import numpy as np
7
  import torch
 
75
  return vc_fn
76
 
77
 
78
+ def system_monitor():
79
+ def get_size(bs, suffix="B"):
80
+ """
81
+ Scale bytes to its proper format
82
+ e.g:
83
+ 1253656 => '1.20MB'
84
+ 1253656678 => '1.17GB'
85
+ """
86
+ factor = 1024
87
+ for unit in ["", "K", "M", "G", "T", "P"]:
88
+ if bs < factor:
89
+ return f"{bs:.2f}{unit}{suffix}"
90
+ bs /= factor
91
+
92
+ def print_sys_status():
93
+ svmem = psutil.virtual_memory()
94
+ swap = psutil.swap_memory()
95
+ print("=" * 10, "CPU & Mem Information", "=" * 10)
96
+ print(f"CPU: {psutil.cpu_percent()}%, "
97
+ f"Mem: {svmem.percent}%({get_size(svmem.total)}), "
98
+ f"SWAP: {swap.percent}%({get_size(swap.total)})")
99
+ print("=" * 10, "Disk Information", "=" * 10)
100
+ # get all disk partitions
101
+ partitions = psutil.disk_partitions()
102
+ disk_info = ""
103
+ for partition in partitions:
104
+ disk_info += f"{partition.mountpoint}: "
105
+ try:
106
+ partition_usage = psutil.disk_usage(partition.mountpoint)
107
+ except PermissionError:
108
+ continue
109
+ disk_info += f"{partition_usage.percent}%({get_size(partition_usage.total)}), "
110
+ print(disk_info)
111
+ tr = Timer(60, print_sys_status)
112
+ tr.start()
113
+
114
+ print_sys_status()
115
+
116
+
117
  css = """
118
  #advanced-btn {
119
  color: white;
 
133
  """
134
 
135
  if __name__ == '__main__':
136
+ system_monitor() # debug
137
  models = []
138
  with open("saved_model/names.json", "r", encoding="utf-8") as f:
139
  models_names = json.load(f)