Spaces:
Build error
Build error
Download src/utils/device_utils.py from HSinghHuggingFace/SmolLM2-135-Text-Generator: direct link, hf CLI and curl.
- Browser
- Download file 254 Bytes
-
https://huggingface.co/spaces/HSinghHuggingFace/SmolLM2-135-Text-Generator/resolve/main/src/utils/device_utils.py
- Command line
-
hf download hf://spaces/HSinghHuggingFace/SmolLM2-135-Text-Generator/src/utils/device_utils.py
-
curl -L -o device_utils.py https://huggingface.co/spaces/HSinghHuggingFace/SmolLM2-135-Text-Generator/resolve/main/src/utils/device_utils.py
254 Bytes
| import torch | |
| def get_device(): | |
| """ | |
| Determine the available device for computation. | |
| Returns either CUDA device if available, or CPU. | |
| """ | |
| if torch.cuda.is_available(): | |
| return torch.device('cuda') | |
| return torch.device('cpu') |