poltextlab commited on
Commit
261d20f
·
verified ·
1 Parent(s): e2e4e4a

debug disk space error

Browse files
Files changed (1) hide show
  1. interfaces/illframes.py +39 -1
interfaces/illframes.py CHANGED
@@ -21,6 +21,27 @@ domains = {
21
  "Migration": "migration"
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  def check_huggingface_path(checkpoint_path: str):
25
  try:
26
  hf_api = HfApi(token=HF_TOKEN)
@@ -34,7 +55,24 @@ def build_huggingface_path(domain: str):
34
 
35
  def predict(text, model_id, tokenizer_id, label_names):
36
  device = torch.device("cpu")
37
- model = AutoModelForSequenceClassification.from_pretrained(model_id, low_cpu_mem_usage=True, device_map="auto", offload_folder="offload", token=HF_TOKEN)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
39
 
40
  inputs = tokenizer(text,
 
21
  "Migration": "migration"
22
  }
23
 
24
+
25
+ # --- DEBUG ---
26
+ import shutil
27
+
28
+ def convert_size(size):
29
+ for unit in ['B', 'KB', 'MB', 'GB', 'TB', 'PB']:
30
+ if size < 1024:
31
+ return f"{size:.2f} {unit}"
32
+ size /= 1024
33
+
34
+ def get_disk_space(path="/"):
35
+ total, used, free = shutil.disk_usage(path)
36
+
37
+ return {
38
+ "Total": convert_size(total),
39
+ "Used": convert_size(used),
40
+ "Free": convert_size(free)
41
+ }
42
+
43
+ # ---
44
+
45
  def check_huggingface_path(checkpoint_path: str):
46
  try:
47
  hf_api = HfApi(token=HF_TOKEN)
 
55
 
56
  def predict(text, model_id, tokenizer_id, label_names):
57
  device = torch.device("cpu")
58
+
59
+ # --- DEBUG ---
60
+
61
+ disk_space = get_disk_space()
62
+ print("Disk Space Info:")
63
+ for key, value in disk_space.items():
64
+ print(f"{key}: {value}")
65
+
66
+ # ---
67
+
68
+ try:
69
+ model = AutoModelForSequenceClassification.from_pretrained(model_id, low_cpu_mem_usage=True, device_map="auto", offload_folder="offload", token=HF_TOKEN)
70
+ except:
71
+ disk_space = get_disk_space()
72
+ print("Disk Space Error:")
73
+ for key, value in disk_space.items():
74
+ print(f"{key}: {value}")
75
+
76
  tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
77
 
78
  inputs = tokenizer(text,