Download backend/device.py from Kingoteam/fastsdcpu: direct link, hf CLI and curl.
- Browser
- Download file 622 Bytes
-
https://huggingface.co/spaces/Kingoteam/fastsdcpu/resolve/main/backend/device.py
- Command line
-
hf download hf://spaces/Kingoteam/fastsdcpu/backend/device.py
-
curl -L -o device.py https://huggingface.co/spaces/Kingoteam/fastsdcpu/resolve/main/backend/device.py
622 Bytes
| import platform | |
| from constants import DEVICE | |
| import torch | |
| import openvino as ov | |
| core = ov.Core() | |
| def is_openvino_device() -> bool: | |
| if DEVICE.lower() == "cpu" or DEVICE.lower()[0] == "g": | |
| return True | |
| else: | |
| return False | |
| def get_device_name() -> str: | |
| if DEVICE == "cuda" or DEVICE == "mps": | |
| default_gpu_index = torch.cuda.current_device() | |
| return torch.cuda.get_device_name(default_gpu_index) | |
| elif platform.system().lower() == "darwin": | |
| return platform.processor() | |
| elif is_openvino_device(): | |
| return core.get_property(DEVICE.upper(), "FULL_DEVICE_NAME") | |