Spaces:
Sleeping
Sleeping
Download src/utils/device.py from Super-Coding/stanford-cars: direct link, hf CLI and curl.
- Browser
- Download file 225 Bytes
-
https://huggingface.co/spaces/Super-Coding/stanford-cars/resolve/main/src/utils/device.py
- Command line
-
hf download hf://spaces/Super-Coding/stanford-cars/src/utils/device.py
-
curl -L -o device.py https://huggingface.co/spaces/Super-Coding/stanford-cars/resolve/main/src/utils/device.py
225 Bytes
| import torch | |
| def get_device(): | |
| if torch.cuda.is_available(): | |
| return torch.device("cuda") | |
| elif torch.backends.mps.is_available(): | |
| return torch.device("mps") | |
| else: | |
| return torch.device("cpu") |