-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
some idea of managing device, also see torch.set_default_device
import torch
from ss.utility.logging import Logging
logger = Logging.get_logger(__name__)
class Device:
@staticmethod
def get() -> torch.device:
"""Get the best available device."""
# Check if CUDA is available
if torch.cuda.is_available():
logger.debug("Using CUDA device.")
return torch.device("cuda")
# Check if MPS (Apple M series chip) is available
if hasattr(torch.backends, "mps") and torch.backends.mps.is_available():
logger.debug("Using MPS device.")
return torch.device("mps")
# If no CUDA or MPS device is available, use CPU
logger.debug("Using CPU device.")
return torch.device("cpu")
in addition, the mps device might be slower than cpu? check this issue.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed