old_tok / paintmind /utils /device_utils.py
tennant's picture
upload
af7c0ce
raw
history blame contribute delete
620 Bytes
import gc
import torch
import importlib.util
def configure_compute_backend():
"""Configure PyTorch compute backend settings for CUDA."""
if torch.cuda.is_available():
torch.backends.cuda.matmul.allow_tf32 = True
torch.backends.cudnn.allow_tf32 = True
torch.backends.cudnn.benchmark = True
torch.backends.cudnn.deterministic = False
else:
raise ValueError("No CUDA available")
def get_device():
"""Get the device to use for training."""
if torch.cuda.is_available():
return torch.device("cuda")
else:
raise ValueError("No CUDA available")