Spaces:
Running
Running
kovacsvi
commited on
Commit
Β·
0a394ee
1
Parent(s):
fb1a253
jit pt2
Browse files
utils.py
CHANGED
@@ -57,7 +57,6 @@ for domain in domains_illframes.values():
|
|
57 |
tokenizers = ["xlm-roberta-large"]
|
58 |
|
59 |
def download_hf_models():
|
60 |
-
return ### DEBUG
|
61 |
# Ensure the JIT model directory exists
|
62 |
os.makedirs(JIT_DIR, exist_ok=True)
|
63 |
|
@@ -107,14 +106,30 @@ def df_h():
|
|
107 |
print(result.stdout)
|
108 |
|
109 |
def scan_cache():
|
|
|
110 |
cache_dir = os.environ.get("TRANSFORMERS_CACHE", os.path.expanduser("~/.cache/huggingface/transformers"))
|
111 |
scan_result = scan_cache_dir(cache_dir)
|
112 |
|
113 |
-
print("=== Model Cache
|
114 |
print(f"Cache size: {scan_result.size_on_disk / 1e6:.2f} MB")
|
115 |
print(f"Number of repos: {len(scan_result.repos)}")
|
116 |
for repo in scan_result.repos:
|
117 |
print(f"- {repo.repo_id} ({repo.repo_type}) β {repo.size_on_disk / 1e6:.2f} MB")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
def set_hf_cache_dir(path:str):
|
120 |
os.environ['TRANSFORMERS_CACHE'] = path
|
|
|
57 |
tokenizers = ["xlm-roberta-large"]
|
58 |
|
59 |
def download_hf_models():
|
|
|
60 |
# Ensure the JIT model directory exists
|
61 |
os.makedirs(JIT_DIR, exist_ok=True)
|
62 |
|
|
|
106 |
print(result.stdout)
|
107 |
|
108 |
def scan_cache():
|
109 |
+
# Scan Hugging Face model cache
|
110 |
cache_dir = os.environ.get("TRANSFORMERS_CACHE", os.path.expanduser("~/.cache/huggingface/transformers"))
|
111 |
scan_result = scan_cache_dir(cache_dir)
|
112 |
|
113 |
+
print("=== π€ Hugging Face Model Cache ===")
|
114 |
print(f"Cache size: {scan_result.size_on_disk / 1e6:.2f} MB")
|
115 |
print(f"Number of repos: {len(scan_result.repos)}")
|
116 |
for repo in scan_result.repos:
|
117 |
print(f"- {repo.repo_id} ({repo.repo_type}) β {repo.size_on_disk / 1e6:.2f} MB")
|
118 |
+
|
119 |
+
print("\n=== π§ TorchScript JIT Cache ===")
|
120 |
+
if not os.path.exists(JIT_DIR):
|
121 |
+
print(f"(Directory does not exist: {JIT_DIR})")
|
122 |
+
return
|
123 |
+
|
124 |
+
total_size = 0
|
125 |
+
for filename in os.listdir(JIT_DIR):
|
126 |
+
if filename.endswith(".pt"):
|
127 |
+
path = os.path.join(JIT_DIR, filename)
|
128 |
+
size = os.path.getsize(path)
|
129 |
+
total_size += size
|
130 |
+
print(f"- {filename}: {size / 1e6:.2f} MB")
|
131 |
+
|
132 |
+
print(f"Total JIT cache size: {total_size / 1e6:.2f} MB")
|
133 |
|
134 |
def set_hf_cache_dir(path:str):
|
135 |
os.environ['TRANSFORMERS_CACHE'] = path
|