Spaces:
Runtime error
Runtime error
| 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() |