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')