Skip to content

Commit 072c141

Browse files
committed
Add helpful logs
1 parent 84e7bd4 commit 072c141

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

optimum/executorch/modeling.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,46 @@ def __del__(self):
120120
"""Clean up temporary files when the model instance is destroyed."""
121121
self._cleanup_temp_resources()
122122

123+
import psutil
124+
125+
for part in psutil.disk_partitions():
126+
usage = psutil.disk_usage(part.mountpoint)
127+
print(f"{part.device} mounted on {part.mountpoint}")
128+
print(f" Total: {usage.total / 2**30:.2f} GB")
129+
print(f" Used: {usage.used / 2**30:.2f} GB")
130+
print(f" Free: {usage.free / 2**30:.2f} GB")
131+
print(f" Percent Used: {usage.percent}%\n")
132+
133+
import os
134+
from pathlib import Path
135+
136+
def get_dir_size(path):
137+
total = 0
138+
for dirpath, dirnames, filenames in os.walk(path, onerror=lambda e: None):
139+
for f in filenames:
140+
try:
141+
fp = os.path.join(dirpath, f)
142+
total += os.path.getsize(fp)
143+
except (FileNotFoundError, PermissionError):
144+
continue
145+
return total
146+
147+
# Compute top 40 largest directories under /
148+
dirs = []
149+
root = Path("/")
150+
151+
for p in root.iterdir():
152+
try:
153+
size = get_dir_size(p)
154+
dirs.append((size, str(p)))
155+
except PermissionError:
156+
continue
157+
158+
# Sort and print largest 40
159+
dirs.sort(reverse=True)
160+
for size, path in dirs[:40]:
161+
print(f"{size / 1e9:.2f} GB\t{path}")
162+
123163
def _cleanup_temp_resources(self):
124164
"""Clean up temporary directory and files."""
125165
if hasattr(self, "_temp_dir") and self._temp_dir is not None:

0 commit comments

Comments
 (0)