SmolLM2-135-Text-Generator / src /utils /device_utils.py
HSinghHuggingFace's picture
Huggingface app
f98cc3f
Raw History Blame Contribute Delete
254 Bytes
import torch
def get_device():
"""
Determine the available device for computation.
Returns either CUDA device if available, or CPU.
"""
if torch.cuda.is_available():
return torch.device('cuda')
return torch.device('cpu')