huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
135.11k stars 27.04k forks source link

AutoModelForCausalLM error with accelerate and bitsandbytes #29882

Closed Altrastorique closed 5 months ago

Altrastorique commented 7 months ago

System Info

Use google colab but connected localy with my computer using jupyter. I have Windows 10, RTX 3070 and no cuda or cudnn because I didn't succed to make it works :(

Who can help?

No response

Information

Tasks

Reproduction

!pip install transformers trl accelerate torch bitsandbytes peft datasets -qU !pip install flash-attn --no-build-isolation

from datasets import load_dataset

instruct_tune_dataset = load_dataset("mosaicml/instruct-v3")

...

model_id = "mistralai/Mixtral-8x7B-v0.1"

from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig import torch

nf4_config = BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True, bnb_4bit_compute_dtype=torch.bfloat16 )

model = AutoModelForCausalLM.from_pretrained( model_id, device_map='auto', quantization_config=nf4_config, use_cache=False, attn_implementation="flash_attention_2"

)

Error message: ImportError: Using bitsandbytes 8-bit quantization requires Accelerate: pip install accelerate and the latest version of bitsandbytes: pip install -i https://pypi.org/simple/ bitsandbytes

Expected behavior

This code works when using the google colab free T4 but don't when I run the code localy. Even if I have installed bitsandbytes and accelerate.

Please help me :) Thank you very much!

ArthurZucker commented 7 months ago

Hey 🤗 thanks for opening an issue! We try to keep the github issues for bugs/feature requests. Could you ask your question on the forum instead? I'm sure the community will be of help!

Thanks!

mauricesvp commented 6 months ago

I ran into the same issue, and the problem likely is that torch.cuda is not available, cf.

src/transformers/utils/import_utils.py#L739-L747

github-actions[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.