Spaces:
Sleeping
Sleeping
Download backend/device.py from michaelj/FastAPI_lcm_docker: direct link, hf CLI and curl.
- Browser
- Download file 622 Bytes
-
https://huggingface.co/spaces/michaelj/FastAPI_lcm_docker/resolve/80f3ced06fb77a542f78b11f06d640046bbd5c4f/backend/device.py
- Command line
-
hf download hf://spaces/michaelj/FastAPI_lcm_docker@80f3ced06fb77a542f78b11f06d640046bbd5c4f/backend/device.py
-
curl -L -o device.py https://huggingface.co/spaces/michaelj/FastAPI_lcm_docker/resolve/80f3ced06fb77a542f78b11f06d640046bbd5c4f/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") | |