Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name 'EncoderDecoderCache' from 'transformers' (F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\transformers\__init__.py) #6248

Open
seemon2 opened this issue Dec 28, 2024 · 5 comments
Labels
Potential Bug User is reporting a bug. This should be tested.

Comments

@seemon2
Copy link

seemon2 commented Dec 28, 2024

Expected Behavior

able to run workflow in attached.

CogVideoX-I2V_00002.mp4

Actual Behavior

error message when attempting to run

Steps to Reproduce

click queue in comfyui on attached workflow

CogVideoX-I2V_00002.mp4

error when running this node.
image

Debug Logs

WARNING: [Errno 2] No such file or directory: 'F:\\ComfyUI_windows_portable\\ComfyUI\\input\\Shotcut_00_01_41_636.png'
[{'path': 'F:\\ComfyUI_windows_portable\\ComfyUI\\models\\CogVideo\\loras\\CogVideoX-Fun-V1.1-5b-InP-MPS.safetensors', 'strength': 1.0, 'name': 'CogVideoX-Fun-V1', 'fuse_lora': False}]
!!! Exception during processing !!! cannot import name 'EncoderDecoderCache' from 'transformers' (F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\transformers\__init__.py)
Traceback (most recent call last):
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 328, in execute
    output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 203, in get_output_data
    return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 174, in _map_node_over_list
    process_inputs(input_dict, i)
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 163, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\ComfyUI_windows_portable/ComfyUI/custom_nodes\ComfyUI-CogVideoXWrapper\model_loading.py", line 297, in loadmodel
    pipe = CogVideoXPipeline(
           ^^^^^^^^^^^^^^^^^^
  File "F:\ComfyUI_windows_portable/ComfyUI/custom_nodes\ComfyUI-CogVideoXWrapper\pipeline_cogvideox.py", line 140, in __init__
    self.register_modules(transformer=transformer, scheduler=scheduler)
  File "F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 165, in register_modules
    library, class_name = _fetch_class_library_tuple(module)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\diffusers\pipelines\pipeline_loading_utils.py", line 755, in _fetch_class_library_tuple
    not_compiled_module = _unwrap_model(module)
                          ^^^^^^^^^^^^^^^^^^^^^
  File "F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\diffusers\pipelines\pipeline_loading_utils.py", line 259, in _unwrap_model
    from peft import PeftModel
  File "F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\peft\__init__.py", line 22, in <module>
    from .auto import (
  File "F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\peft\auto.py", line 32, in <module>
    from .mapping import MODEL_TYPE_TO_PEFT_MODEL_MAPPING
  File "F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\peft\mapping.py", line 25, in <module>
    from .mixed_model import PeftMixedModel
  File "F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\peft\mixed_model.py", line 29, in <module>
    from .peft_model import PeftModel
  File "F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\peft\peft_model.py", line 37, in <module>
    from transformers import Cache, DynamicCache, EncoderDecoderCache, PreTrainedModel
ImportError: cannot import name 'EncoderDecoderCache' from 'transformers' (F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\transformers\__init__.py)

Other

someone suggested this solution ..
treeaaa/ilovechatgpt#2

ImportError: cannot import name 'EncoderDecoderCache' from 'transformers'
AiuniAI/Unique3D#123
pip install --upgrade transformers

I ran this "pip" command string in windows "cmd" terminal at directory F:\ComfyUI_windows_portable\python_embeded

@seemon2 seemon2 added the Potential Bug User is reporting a bug. This should be tested. label Dec 28, 2024
@LukeG89
Copy link

LukeG89 commented Dec 28, 2024

Have you ran the command this way? (to upgrade transformers in your python embedded)

.\python.exe -m pip install --upgrade transformers

@seemon2
Copy link
Author

seemon2 commented Dec 29, 2024

Hi ..
Thanks. I tried with your command and managed to successfully install transformers-4.47.1 (previously transformers-4.42.4)
However when I tried to run my workflow, still encounter same error ..

** Error on pop up screen in comfyui.
cannot import name 'EncoderDecoderCache' from 'transformers' (F:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\transformers_init_.py)

** console log for the successful transformer pip install for reference.
Attempting uninstall: transformers
Found existing installation: transformers 4.42.4
Uninstalling transformers-4.42.4:
Successfully uninstalled transformers-4.42.4
WARNING: The script transformers-cli.exe is installed in 'F:\ComfyUI_windows_portable\python_embeded\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed tokenizers-0.21.0 transformers-4.47.1

@LukeG89
Copy link

LukeG89 commented Dec 29, 2024

Maybe you have to update diffusers as well?

@anakein
Copy link

anakein commented Jan 7, 2025

i have same problem

@LukeG89
Copy link

LukeG89 commented Jan 7, 2025

i have same problem

@anakein If you have ComfyUI portable, you can open terminal inside python_embeded folder and run this command to update both transformers and diffusers, that should fix the issue

.\python.exe -m pip install --upgrade transformers diffusers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Potential Bug User is reporting a bug. This should be tested.
Projects
None yet
Development

No branches or pull requests

3 participants