pytorch 无法从“flash_attn”导入名称“flash_attn_func”

ivqmmu1c  于 2023-10-20  发布在  其他
关注(0)|答案(1)|浏览(914)

尝试加载llama2模型:

model = AutoModelForCausalLM.from_pretrained(
    model_name,
    quantization_config=bnb_config,
    device_map=device_map
)

使用bnb_config:

BitsAndBytesConfig {
  "bnb_4bit_compute_dtype": "bfloat16",
  "bnb_4bit_quant_type": "nf4",
  "bnb_4bit_use_double_quant": true,
  "llm_int8_enable_fp32_cpu_offload": false,
  "llm_int8_has_fp16_weight": false,
  "llm_int8_skip_modules": null,
  "llm_int8_threshold": 6.0,
  "load_in_4bit": true,
  "load_in_8bit": false,
  "quant_method": "bitsandbytes"
}

我得到这个错误:

RuntimeError: Failed to import transformers.models.llama.modeling_llama because of the following error (look up to see its traceback):
cannot import name 'flash_attn_func' from 'flash_attn' (/opt/conda/lib/python3.10/site-packages/flash_attn/__init__.py)

任何帮助都会有帮助。

pkwftd7m

pkwftd7m1#

我在微调llama2模型时也遇到了同样的错误,解决方案是恢复到以前的变形金刚版本。

pip install transformers==4.33.1 --upgrade

这个应该能用

相关问题