turtle170 commited on
Commit
a2ffed4
·
verified ·
1 Parent(s): 0c27b45

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -1234,12 +1234,21 @@ class ZeroEngine:
1234
  logger.warning(f"[BOOT] Cleanup warning: {e}")
1235
 
1236
  # Calculate optimal parameters with token purchases
1237
- # Use actual system RAM detection
1238
  import psutil
1239
  ram = psutil.virtual_memory()
1240
  total_ram_gb = ram.total / (1024**3)
1241
  available_ram_gb = ram.available / (1024**3)
1242
- logger.info(f"[RAM] Total: {total_ram_gb:.1f}GB, Available: {available_ram_gb:.1f}GB")
 
 
 
 
 
 
 
 
 
1243
 
1244
  # CPU-OPTIMIZED BATCH CALCULATION - Very aggressive for 16GB RAM
1245
  # Base calculation: use more RAM for batching on CPU
 
1234
  logger.warning(f"[BOOT] Cleanup warning: {e}")
1235
 
1236
  # Calculate optimal parameters with token purchases
1237
+ # FIX: Use container RAM limits, not host system memory
1238
  import psutil
1239
  ram = psutil.virtual_memory()
1240
  total_ram_gb = ram.total / (1024**3)
1241
  available_ram_gb = ram.available / (1024**3)
1242
+
1243
+ # CRITICAL FIX: Force realistic container limits for Hugging Face Spaces
1244
+ # The host shows 123.8GB but container only has 16GB total
1245
+ if total_ram_gb > 50.0: # Host system memory detected
1246
+ logger.warning(f"[RAM] Host system memory detected ({total_ram_gb:.1f}GB), forcing container limits")
1247
+ total_ram_gb = 16.0 # Container limit
1248
+ available_ram_gb = min(available_ram_gb, 11.0) # Conservative available RAM
1249
+ logger.info(f"[RAM] FORCED: Total: {total_ram_gb:.1f}GB, Available: {available_ram_gb:.1f}GB")
1250
+ else:
1251
+ logger.info(f"[RAM] Total: {total_ram_gb:.1f}GB, Available: {available_ram_gb:.1f}GB")
1252
 
1253
  # CPU-OPTIMIZED BATCH CALCULATION - Very aggressive for 16GB RAM
1254
  # Base calculation: use more RAM for batching on CPU