fix(model-loaders): add local_files_only=True to prevent network requests#8735
Conversation
…ests When loading models, HuggingFace's from_pretrained() would attempt to connect to the internet for validation or updates, causing generation to hang when network is unavailable or slow. Added local_files_only=True to all model loaders: - stable_diffusion.py (SD1, SD2, SDXL, SDXLRefiner, SD3) - generic_diffusers.py (T2IAdapter) - flux.py (CLIP, T5 Tokenizer/Encoder) - cogview4.py - onnx.py
|
Good to get all these fixes in. I will test tomorrow. Might or might not get into RC2. |
lstein
left a comment
There was a problem hiding this comment.
I've tested with examples from SD1, SD2, SD3, SDXL, Cogview, Flux and Z-Image, and all models loaded and ran with the internet disconnected.
Question: There are several loaders which call class.from_single_file() to load checkpoint-style models. This also takes a local_files_only parameter, but it doesn't seem to be needed to load offline. Is there any merit to adding the parameter?
In case of my issue, models loaded fine if internet just disconnected. But when it's connected, but HuggingFace is unreachable, then models unable to load. |
|
I think the problem is the config HuggingFace wants is gone(?) and that is the problem if the parameter is not there it will fail. |
It was because my Internet Service Provider blocking access to Cloudflare Protection Services. All other services that relies on Cloudflare could not be accessible |
Summary
Add
local_files_only=Trueto all model loaderfrom_pretrained()calls to prevent network requests during model loading.When loading models, HuggingFace's
from_pretrained()attempts to connect to the internet for validation or updates. This causes generation to hang or fail when the network is unavailable, slow, or behind a proxy.Affected loaders:
stable_diffusion.py- SD1, SD2, SDXL, SDXLRefiner, SD3generic_diffusers.py- T2IAdapter and generic modelsflux.py- CLIP and T5 Tokenizer/Encodercogview4.py- CogView4 modelsonnx.py- ONNX modelsRelated Issues / Discussions
User report: #8630
QA Instructions
Merge Plan
Standard merge - no special handling required.
Checklist
What's Newcopy (if doing a release after this PR)