Skip to content

ImportError: cannot import name 'cached_download' from 'huggingface_hub'Β #92

@MoritzLaurer

Description

@MoritzLaurer

A dedicated inference endpoint using a custom handler just failed with the error below.
I think the cause is that huggingface_hub version 2.6.0 has removed the cached_download method and the endpoint seems to use this latest version (?), but huggingface-inference-toolkit still uses an older version huggingface_hub[hf_transfer]==0.24.5 (source).

Exit code: 1. Reason: ng(self.app)
  File "/usr/local/lib/python3.10/dist-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/app/webservice_starlette.py", line 19, in <module>
    from huggingface_inference_toolkit.handler import get_inference_handler_either_custom_or_default_handler
  File "/app/huggingface_inference_toolkit/handler.py", line 5, in <module>
    from huggingface_inference_toolkit.utils import check_and_register_custom_pipeline_from_directory, get_pipeline
  File "/app/huggingface_inference_toolkit/utils.py", line 13, in <module>
    from huggingface_inference_toolkit.diffusers_utils import (
  File "/app/huggingface_inference_toolkit/diffusers_utils.py", line 18, in <module>
    from diffusers import AutoPipelineForText2Image, DPMSolverMultistepScheduler, StableDiffusionPipeline
  File "/usr/local/lib/python3.10/dist-packages/diffusers/__init__.py", line 5, in <module>
    from .utils import (
  File "/usr/local/lib/python3.10/dist-packages/diffusers/utils/__init__.py", line 38, in <module>
    from .dynamic_modules_utils import get_class_from_dynamic_module
  File "/usr/local/lib/python3.10/dist-packages/diffusers/utils/dynamic_modules_utils.py", line 28, in <module>
    from huggingface_hub import cached_download, hf_hub_download, model_info
ImportError: cannot import name 'cached_download' from 'huggingface_hub' (/usr/local/lib/python3.10/dist-packages/huggingface_hub/__init__.py)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions