GPT2_Demo / utils.py
peeyushsinghal's picture
Gradio App
6285ada verified
raw
history blame contribute delete
304 Bytes
import torch
def get_device():
if torch.cuda.is_available():
return "cuda"
elif torch.backends.mps.is_available():
return "mps"
else:
return "cpu"
def set_seed(seed):
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed(seed)