Spaces:
Runtime error
Runtime error
File size: 1,782 Bytes
6e790f0 76166e3 271a1f5 76166e3 6e790f0 d28913a 6e790f0 d28913a 6e790f0 d28913a 6e790f0 76166e3 271a1f5 76166e3 271a1f5 d28913a 6e790f0 d28913a 271a1f5 66df45a 271a1f5 66df45a 6e790f0 d28913a 271a1f5 76166e3 |
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 58 59 60 |
import os
import torch
import logging
from interface.app import WellnessInterface
from config.config import load_config
from utils.log_manager import LogManager
def setup_environment():
"""Setup environment variables and device configuration"""
# Force CPU usage and disable GPU
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
os.environ["TRANSFORMERS_OFFLINE"] = "1"
os.environ["TORCH_DEVICE"] = "cpu"
# Disable CUDA initialization
torch.cuda.is_available = lambda: False
# Set PyTorch to use CPU
if hasattr(torch, 'set_default_tensor_type'):
torch.set_default_tensor_type('torch.FloatTensor')
return "cpu"
def main():
# Initialize logging
log_manager = LogManager()
logger = log_manager.get_agent_logger("main")
logger.info("Starting Mental Wellness Platform")
try:
# Setup environment before anything else
device = setup_environment()
logger.info(f"Using device: {device}")
# Disable GPU memory allocation
torch.cuda.empty_cache()
# Load configuration
config = load_config()
logger.info("Configuration loaded successfully")
# Initialize interface
interface = WellnessInterface(config)
logger.info("Interface initialized")
# Launch the application
interface.launch(
server_name="0.0.0.0",
server_port=7860,
show_error=True, # Show detailed error messages
root_path="", # Empty root path for Spaces
quiet=True # Reduce logging noise
)
except Exception as e:
logger.error(f"Error starting application: {str(e)}")
raise
if __name__ == "__main__":
main() |