Qwen-Image-Edit-Fast / start_zero_gpu.py
sunny1997's picture
Updated the Mesh Edit UI
d842ac6
Raw History Blame Contribute Delete
2.27 kB
#!/usr/bin/env python3
"""
Startup script for Hugging Face Zero GPU environments
Prevents infinite TorchInductor warning loops and ensures proper startup.
"""
import os
import sys
import warnings
def setup_zero_gpu_environment():
"""Setup environment variables and warnings for Zero GPU."""
print("🌐 Setting up Hugging Face Zero GPU environment...")
# Disable all problematic PyTorch features
os.environ["TORCH_LOGS"] = "off"
os.environ["TORCH_COMPILE_DEBUG"] = "0"
os.environ["TORCH_SHOW_CPP_STACKTRACES"] = "0"
os.environ["TORCH_USE_CUDA_DSA"] = "0"
os.environ["CUDA_LAUNCH_BLOCKING"] = "0"
os.environ["TORCH_COMPILE"] = "0"
os.environ["TORCH_DYNAMO_DISABLE"] = "1"
# Memory optimization
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:64"
# Suppress all problematic warnings
warnings.filterwarnings("ignore", category=UserWarning, module="torch._inductor")
warnings.filterwarnings("ignore", message=".*aten.unsqueeze.default is missing a c-shim implementation.*")
warnings.filterwarnings("ignore", message=".*using proxy executor as fallback.*")
warnings.filterwarnings("ignore", message=".*Torchinductor.*")
warnings.filterwarnings("ignore", message=".*cudagraphs.*")
warnings.filterwarnings("ignore", message=".*Not enough SMs.*")
print("✅ Zero GPU environment configured")
print("✅ TorchInductor warnings suppressed")
print("✅ Ready to start application")
def main():
"""Main startup function."""
# Check if we're in Zero GPU environment
if not (os.environ.get("SPACE_ID") and "zero" in os.environ.get("SPACE_ID", "").lower()):
print("⚠️ Not running in Zero GPU environment")
print("Starting with standard configuration...")
os.system("python app.py")
return
# Setup Zero GPU environment
setup_zero_gpu_environment()
# Start the application
print("\n🚀 Starting Qwen Face Infusion application...")
try:
os.system("python app.py")
except KeyboardInterrupt:
print("\n🛑 Application stopped by user")
except Exception as e:
print(f"\n❌ Error starting application: {e}")
if __name__ == "__main__":
main()