Spaces:
Sleeping
Sleeping
| """ | |
| File managing utility functions for the application. | |
| Contains the function to load the best available device for computation. | |
| """ | |
| import torch | |
| def load_device(): | |
| """ | |
| Determine the best available device (GPU or CPU) for computation. | |
| Returns: | |
| str: "cuda" if GPU is available, otherwise "cpu" | |
| """ | |
| try: | |
| device = "cuda" if torch.cuda.is_available() else "cpu" | |
| print(f"Using device: {device}") | |
| if device == "cuda": | |
| print("GPU Name:", torch.cuda.get_device_name(0)) | |
| return device | |
| except Exception as e: | |
| print(f"Error loading device: {str(e)}") | |
| return "cpu" |