Download utils/device_utils.py from svjack/FramePack_Image_Edit_Lora_Early: direct link, hf CLI and curl.
- Browser
- Download file 472 Bytes
-
https://huggingface.co/svjack/FramePack_Image_Edit_Lora_Early/resolve/refs%2Fpr%2F1/utils/device_utils.py
- Command line
-
hf download hf://svjack/FramePack_Image_Edit_Lora_Early@refs/pr/1/utils/device_utils.py
-
curl -L -o device_utils.py https://huggingface.co/svjack/FramePack_Image_Edit_Lora_Early/resolve/refs%2Fpr%2F1/utils/device_utils.py
472 Bytes
| import torch | |
| def clean_memory_on_device(device): | |
| if device.type == "cuda": | |
| torch.cuda.empty_cache() | |
| elif device.type == "cpu": | |
| pass | |
| elif device.type == "mps": # not tested | |
| torch.mps.empty_cache() | |
| def synchronize_device(device: torch.device): | |
| if device.type == "cuda": | |
| torch.cuda.synchronize() | |
| elif device.type == "xpu": | |
| torch.xpu.synchronize() | |
| elif device.type == "mps": | |
| torch.mps.synchronize() | |