python - PEFT library installed but PEFT is not identified at runtime - Stack Overflow

时间: 2025-01-06 admin 业界

I am trying to inference a model ChemVLM (). While trying to run the python code, I get error

ImportError: This modeling file requires the following packages that were not found in your environment: peft. Run pip install peft

But my, "pip list" from the environment shows that peft is installed.

env$ pip list | grep peft                                                                                            
peft                     0.14.0**

The error happens at the location:

model = AutoModel.from_pretrained(
    path,
    torch_dtype=torch.bfloat16,
    low_cpu_mem_usage=True,
    trust_remote_code=True).eval().cuda()

Error dump:

Traceback (most recent call last):
  File "/home/expert/chemvlm26/vlm26.py", line 104, in <module>
    model = AutoModel.from_pretrained(
  File "/home/expert/.local/share/virtualenvs/env-7PoxgyG5/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 553, in from_pretrained
    model_class = get_class_from_dynamic_module(\
  File "/home/expert/.local/share/virtualenvs/env-7PoxgyG5/lib/python3.10/site-packages/transformers/dynamic_module_utils.py", line 488, in get_class_from_dynamic_modul
e
    final_module = get_cached_module_file(\
  File "/home/expert/.local/share/virtualenvs/env-7PoxgyG5/lib/python3.10/site-packages/transformers/dynamic_module_utils.py", line 315, in get_cached_module_file
    modules_needed = check_imports(resolved_module_file)\
  File "/home/expert/.local/share/virtualenvs/env-7PoxgyG5/lib/python3.10/site-packages/transformers/dynamic_module_utils.py", line 180, in check_imports
    raise ImportError(\
ImportError: This modeling file requires the following packages that were not found in your environment: peft. Run `pip install peft`

What could be the reason?

最新文章