Spaces:
Configuration error
Configuration error
Download unipixel/utils/env.py from PolyU-ChenLab/UniPixel: direct link, hf CLI and curl.
- Browser
- Download file 319 Bytes
-
https://huggingface.co/spaces/PolyU-ChenLab/UniPixel/resolve/main/unipixel/utils/env.py
- Command line
-
hf download hf://spaces/PolyU-ChenLab/UniPixel/unipixel/utils/env.py
-
curl -L -o env.py https://huggingface.co/spaces/PolyU-ChenLab/UniPixel/resolve/main/unipixel/utils/env.py
319 Bytes
| # Copyright (c) 2025 Ye Liu. Licensed under the BSD-3-Clause License. | |
| import torch | |
| def get_auto_device(): | |
| try: | |
| import torch_npu | |
| has_npu = torch_npu.npu.is_available() | |
| except ImportError: | |
| has_npu = False | |
| return 'cuda' if torch.cuda.is_available() else 'npu' if has_npu else 'cpu' | |