Spaces:
Sleeping
Sleeping
Commit
·
62f4595
1
Parent(s):
41e58ab
Fix initial bugs
Browse files
app.py
CHANGED
|
@@ -345,9 +345,13 @@ class WebGameEngine:
|
|
| 345 |
'/app' in os.getcwd()
|
| 346 |
])
|
| 347 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
compile_enabled = (device.type == "cuda" and
|
| 349 |
-
|
| 350 |
-
not is_hf_spaces)
|
| 351 |
|
| 352 |
if compile_enabled:
|
| 353 |
logger.info("Compiling models for faster inference (like play.py --compile)...")
|
|
@@ -360,7 +364,12 @@ class WebGameEngine:
|
|
| 360 |
logger.warning(f"⚠️ Model compilation failed: {e}")
|
| 361 |
logger.info("Continuing without model compilation...")
|
| 362 |
else:
|
| 363 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
logger.info(f"Model compilation disabled ({reason}). Models will run uncompiled.")
|
| 365 |
|
| 366 |
# Reset environment
|
|
|
|
| 345 |
'/app' in os.getcwd()
|
| 346 |
])
|
| 347 |
|
| 348 |
+
# Allow forcing compilation on HF Spaces with FORCE_TORCH_COMPILE=1
|
| 349 |
+
force_compile = os.getenv("FORCE_TORCH_COMPILE", "0") == "1"
|
| 350 |
+
disable_compile = os.getenv("DISABLE_TORCH_COMPILE", "0") == "1"
|
| 351 |
+
|
| 352 |
compile_enabled = (device.type == "cuda" and
|
| 353 |
+
not disable_compile and
|
| 354 |
+
(force_compile or not is_hf_spaces))
|
| 355 |
|
| 356 |
if compile_enabled:
|
| 357 |
logger.info("Compiling models for faster inference (like play.py --compile)...")
|
|
|
|
| 364 |
logger.warning(f"⚠️ Model compilation failed: {e}")
|
| 365 |
logger.info("Continuing without model compilation...")
|
| 366 |
else:
|
| 367 |
+
if disable_compile:
|
| 368 |
+
reason = "DISABLE_TORCH_COMPILE=1"
|
| 369 |
+
elif is_hf_spaces and not force_compile:
|
| 370 |
+
reason = "HF Spaces detected (use FORCE_TORCH_COMPILE=1 to override)"
|
| 371 |
+
else:
|
| 372 |
+
reason = "no CUDA device"
|
| 373 |
logger.info(f"Model compilation disabled ({reason}). Models will run uncompiled.")
|
| 374 |
|
| 375 |
# Reset environment
|