Spaces:
Sleeping
Sleeping
File size: 651 Bytes
04ca1b2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
"""
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" |