Download src/controlnet_image_generator/inference/device_manager.py from danhtran2mind/ControlNet-Image-Generator: direct link, hf CLI and curl.
- Browser
- Download file 207 Bytes
-
https://huggingface.co/spaces/danhtran2mind/ControlNet-Image-Generator/resolve/main/src/controlnet_image_generator/inference/device_manager.py
- Command line
-
hf download hf://spaces/danhtran2mind/ControlNet-Image-Generator/src/controlnet_image_generator/inference/device_manager.py
-
curl -L -o device_manager.py https://huggingface.co/spaces/danhtran2mind/ControlNet-Image-Generator/resolve/main/src/controlnet_image_generator/inference/device_manager.py
207 Bytes
| import torch | |
| def setup_device(pipe): | |
| device = "cuda" if torch.cuda.is_available() else "cpu" | |
| if device == "cuda": | |
| pipe.enable_model_cpu_offload() | |
| pipe.to(device) | |
| return device |