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' #2292

Open
4 tasks
Huang-jia-xuan opened this issue Dec 21, 2024 · 1 comment
Open
4 tasks

Cannot import name 'EncoderDecoderCache' from 'transformers' #2292

Huang-jia-xuan opened this issue Dec 21, 2024 · 1 comment

Comments

@Huang-jia-xuan
Copy link

System Info

transformer==4.39.3;peft==0.14.0

Maybe this is from transformer's update,so which version can i use.

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder
  • My own task or dataset (give details below)

Reproduction

from src import models
from src.utils import IImage, resize
import numpy as np
from src.methods import rasg, sd, sr
from PIL import Image
from peft import get_peft_model, LoraConfig, TaskType
inp_model = models.load_inpainting_model('ds8_inp', device='cpu', cache=True)
lora_config = LoraConfig(
task_type=TaskType.IMAGE_GENERATION,
inference_mode=True,
r=8,
lora_alpha=16,
lora_dropout=0.05,
)
new_model = get_peft_model(inp_model.unet, lora_config)
print(new_model.state_dict().keys())

Expected behavior

/root/miniconda3/lib/python3.10/site-packages/timm/models/layers/init.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
warnings.warn(f"Importing from {name} is deprecated, please import via timm.layers", FutureWarning)
Traceback (most recent call last):
File "/root/autodl-tmp/workspace/HD-Painter/paratest.py", line 6, in
from peft import get_peft_model, LoraConfig, TaskType
File "/root/miniconda3/lib/python3.10/site-packages/peft/init.py", line 22, in
from .auto import (
File "/root/miniconda3/lib/python3.10/site-packages/peft/auto.py", line 32, in
from .mapping import MODEL_TYPE_TO_PEFT_MODEL_MAPPING
File "/root/miniconda3/lib/python3.10/site-packages/peft/mapping.py", line 25, in
from .mixed_model import PeftMixedModel
File "/root/miniconda3/lib/python3.10/site-packages/peft/mixed_model.py", line 29, in
from .peft_model import PeftModel
File "/root/miniconda3/lib/python3.10/site-packages/peft/peft_model.py", line 37, in
from transformers import Cache, DynamicCache, EncoderDecoderCache, PreTrainedModel
ImportError: cannot import name 'Cache' from 'transformers' (/root/miniconda3/lib/python3.10/site-packages/transformers/init.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants