Download PSIVG/lsa/lang_sam/models/utils.py from AIGeeksGroup/PhysicalWM: direct link, hf CLI and curl.
- Browser
- Download file 600 Bytes
-
https://huggingface.co/datasets/AIGeeksGroup/PhysicalWM/resolve/main/PSIVG/lsa/lang_sam/models/utils.py
- Command line
-
hf download hf://datasets/AIGeeksGroup/PhysicalWM/PSIVG/lsa/lang_sam/models/utils.py
-
curl -L -o utils.py https://huggingface.co/datasets/AIGeeksGroup/PhysicalWM/resolve/main/PSIVG/lsa/lang_sam/models/utils.py
600 Bytes
| import logging | |
| import torch | |
| def get_device_type() -> str: | |
| if torch.backends.mps.is_available(): | |
| return "mps" | |
| elif torch.cuda.is_available(): | |
| return "cuda" | |
| else: | |
| logging.warning("No GPU found, using CPU instead") | |
| return "cpu" | |
| device_type = get_device_type() | |
| DEVICE = torch.device(device_type) | |
| if torch.cuda.is_available(): | |
| torch.autocast(device_type="cuda", dtype=torch.bfloat16).__enter__() | |
| if torch.cuda.get_device_properties(0).major >= 8: | |
| torch.backends.cuda.matmul.allow_tf32 = True | |
| torch.backends.cudnn.allow_tf32 = True | |