File size: 1,862 Bytes
85442be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
Diagnostic : vérifie si le cache HuggingFace persiste sur /data
Usage: python check_cache.py
"""

import os
import json
from pathlib import Path

HF_HOME = os.getenv("HF_HOME", "/data/.cache/huggingface")
CACHE_DIR = Path(HF_HOME)

print("=" * 60)
print("DIAGNOSTIC CACHE HUGGINGFACE")
print("=" * 60)

print(f"\nHF_HOME: {HF_HOME}")
print(f"CACHE_DIR: {CACHE_DIR}")
print(f"CACHE_DIR exists: {CACHE_DIR.exists()}")

if CACHE_DIR.exists():
    print(f"CACHE_DIR is writable: {os.access(CACHE_DIR, os.W_OK)}")
    
    hub_dir = CACHE_DIR / "hub"
    print(f"\nhub/ exists: {hub_dir.exists()}")
    
    if hub_dir.exists():
        models = list(hub_dir.glob("models--*"))
        print(f"Models cached: {len(models)}")
        for m in models[:5]:
            size = sum(f.stat().st_size for f in m.rglob("*") if f.is_file())
            print(f"  - {m.name}: {size / 1024**3:.1f} GB")
        
        datasets_dir = CACHE_DIR / "datasets"
        print(f"\ndatasets/ exists: {datasets_dir.exists()}")
        if datasets_dir.exists():
            datasets = list(datasets_dir.glob("*"))
            print(f"Datasets cached: {len(datasets)}")
            for d in datasets[:5]:
                print(f"  - {d.name}")
    else:
        print("No hub/ directory — cache is empty")
else:
    print("CACHE_DIR does not exist — will be created on first use")

print("\n" + "=" * 60)
print("RECOMMENDATION:")
print("=" * 60)
if not CACHE_DIR.exists() or not os.access(CACHE_DIR, os.W_OK):
    print("⚠️  /data is NOT persistent or NOT writable")
    print("   → Cache will be lost on restart")
    print("   → Each reboot = ~17 min re-download")
    print("   → Solution: Enable persistent storage in Space Settings")
else:
    print("✅ /data is accessible and writable")
    print("   → Cache should persist between restarts")
print("=" * 60)