diffusers: ValueError: invalid version number '0.17.0rc0'
Describe the bug
Loading a diffusion model broke suddenly.
I’ve already tried pip reinstalling diffusers (from pip as well as this github repo)
Reproduction
from diffusers import DiffusionPipeline import torch
model_id = “runwayml/stable-diffusion-v1-5”
ref_pipe = DiffusionPipeline.from_pretrained( model_id, # revision=revision, custom_pipeline=“stable_diffusion_reference”, torch_dtype=torch.float16, use_auth_token=True, cache_dir=“./AI/StableDiffusion” )
Logs
─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\Nagol\AppData\Local\Temp\ipykernel_68840\2161590897.py:6 in <module> │
│ │
│ [Errno 2] No such file or directory: │
│ 'C:\\Users\\Nagol\\AppData\\Local\\Temp\\ipykernel_68840\\2161590897.py' │
│ │
│ C:\Users\Nagol\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\pipelines\pip │
│ eline_utils.py:884 in from_pretrained │
│ │
│ 881 │ │ # 1. Download the checkpoints and configs │
│ 882 │ │ # use snapshot download here to get it working from from_pretrained │
│ 883 │ │ if not os.path.isdir(pretrained_model_name_or_path): │
│ ❱ 884 │ │ │ cached_folder = cls.download( │
│ 885 │ │ │ │ pretrained_model_name_or_path, │
│ 886 │ │ │ │ cache_dir=cache_dir, │
│ 887 │ │ │ │ resume_download=resume_download, │
│ │
│ C:\Users\Nagol\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\pipelines\pip │
│ eline_utils.py:1265 in download │
│ │
│ 1262 │ │ │ ] │
│ 1263 │ │ │ │
│ 1264 │ │ │ # retrieve passed components that should not be downloaded │
│ ❱ 1265 │ │ │ pipeline_class = _get_pipeline_class( │
│ 1266 │ │ │ │ cls, config_dict, custom_pipeline=custom_pipeline, cache_dir=cache_dir, │
│ 1267 │ │ │ ) │
│ 1268 │ │ │ expected_components, _ = cls._get_signature_keys(pipeline_class) │
│ │
│ C:\Users\Nagol\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\pipelines\pip │
│ eline_utils.py:336 in _get_pipeline_class │
│ │
│ 333 │ │ else: │
│ 334 │ │ │ file_name = CUSTOM_PIPELINE_FILE_NAME │
│ 335 │ │ │
│ ❱ 336 │ │ return get_class_from_dynamic_module( │
│ 337 │ │ │ custom_pipeline, module_file=file_name, cache_dir=cache_dir, revision=revisi │
│ 338 │ │ ) │
│ 339 │
│ │
│ C:\Users\Nagol\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\utils\dynamic │
│ _modules_utils.py:445 in get_class_from_dynamic_module │
│ │
│ 442 │ cls = get_class_from_dynamic_module("sgugger/my-bert-model", "modeling.py", "MyBertM │
│ 443 │ """ │
│ 444 │ # And lastly we get the class inside our newly created module │
│ ❱ 445 │ final_module = get_cached_module_file( │
│ 446 │ │ pretrained_model_name_or_path, │
│ 447 │ │ module_file, │
│ 448 │ │ cache_dir=cache_dir, │
│ │
│ C:\Users\Nagol\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\utils\dynamic │
│ _modules_utils.py:264 in get_cached_module_file │
│ │
│ 261 │ │ resolved_module_file = module_file_or_url │
│ 262 │ │ submodule = "local" │
│ 263 │ elif pretrained_model_name_or_path.count("/") == 0: │
│ ❱ 264 │ │ available_versions = get_diffusers_versions() │
│ 265 │ │ # cut ".dev0" │
│ 266 │ │ latest_version = "v" + ".".join(__version__.split(".")[:3]) │
│ 267 │
│ │
│ C:\Users\Nagol\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\utils\dynamic │
│ _modules_utils.py:46 in get_diffusers_versions │
│ │
│ 43 def get_diffusers_versions(): │
│ 44 │ url = "https://pypi.org/pypi/diffusers/json" │
│ 45 │ releases = json.loads(request.urlopen(url).read())["releases"].keys() │
│ ❱ 46 │ return sorted(releases, key=StrictVersion) │
│ 47 │
│ 48 │
│ 49 def init_hf_modules(): │
│ │
│ C:\Users\Nagol\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\v │
│ ersion.py:54 in __init__ │
│ │
│ 51 │ │
│ 52 │ def __init__(self, vstring=None): │
│ 53 │ │ if vstring: │
│ ❱ 54 │ │ │ self.parse(vstring) │
│ 55 │ │ warnings.warn( │
│ 56 │ │ │ "distutils Version classes are deprecated. " │
│ 57 │ │ │ "Use packaging.version instead.", │
│ │
│ C:\Users\Nagol\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\v │
│ ersion.py:157 in parse │
│ │
│ 154 │ def parse(self, vstring): │
│ 155 │ │ match = self.version_re.match(vstring) │
│ 156 │ │ if not match: │
│ ❱ 157 │ │ │ raise ValueError("invalid version number '%s'" % vstring) │
│ 158 │ │ │
│ 159 │ │ (major, minor, patch, prerelease, prerelease_num) = match.group(1, 2, 4, 5, 6) │
│ 160 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: invalid version number '0.17.0rc0'
System Info
windows+python3.10
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 4
- Comments: 29 (8 by maintainers)
@ryancustomuse there is a simpler version of fix w/o storing the json locally:
same issue @patil-suraj @patrickvonplaten ,
Why there is no offline mode? Like, i want diffusers to work without making any api call to any remote URL
our 80 servers are down due to this,
Aiii, the custom pipelines again 😕 We need to test here better! Super sorry, fixing now
Having the same issue
@vicky-aipaintr Sure. Here’s what I did.
lpw_stable_diffusion
.lpw_stable_diffusion/pipeline.py
"lpw_stable_diffusion"
to"./lpw_stable_diffusion/."
so that it knows to load it from the local directory.This same process should work for other custom pipelines as well.
Thanks for fix - you could always do 0.17.0a0 as StrictVersion will parse that fine - it just won’t allow “rc” Not ideal, but would be backwards compat
@vicky-aipaintr You can also keep
lpw_stable_diffusion.py
in your project locally & importStableDiffusionLongPromptWeightingPipeline
to instantiate it manually via.from_pretrained(...)
method.Thanks for fixing this @patrickvonplaten. If this is only related to community pipelines maybe the only way to run them should be by downloading them locally as mentioned by @joshuacc .
Agreed I run a full test suite where I try to simulate the hub being offline, but I do so by setting a bunch of huggingface hosts to 127.0.0.1 in /etc/hosts, and this slipped through because its actually pulling from pypi.org We would all have the same issue if pypi.org was down or failed to resolve, even with local_files_only
Same issue. I set local_files_only=True, HF_HUB_OFFLINE=1, etc when running diffusers to avoid issues like this, but this still has brought down all the servers as they can’t load pipelines
We are going to try and patch over that file with this updated function
Just get the json from ‘https://pypi.org/pypi/diffusers/json’ and remove the bad version
The issue lies here:
def get_diffusers_versions(): url = "https://pypi.org/pypi/diffusers/json" releases = json.loads(request.urlopen(url).read())["releases"].keys() return sorted(releases, key=StrictVersion)
The url they are requesting versions on is pulling this broken RC version