Spaces:
Running
Running
File size: 330 Bytes
b4f3263 |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import torch
class DeviceManager:
_instance = None
def __new__(cls):
if cls._instance is None:
cls._instance = super(DeviceManager, cls).__new__(cls)
cls._instance.device = torch.device(
"cuda" if torch.cuda.is_available() else "cpu")
return cls._instance.device
|