Repository navigation
Description
I want to download Llama 3.2 Vision Instruct Model with this code but I take an error
`from unsloth import FastVisionModel # FastLanguageModel for LLMs
import torch
4bit pre quantized models we support for 4x faster downloading + no OOMs.
fourbit_models = [
"unsloth/Llama-3.2-11B-Vision-Instruct-bnb-4bit", # Llama 3.2 vision support
"unsloth/Llama-3.2-11B-Vision-bnb-4bit",
"unsloth/Llama-3.2-90B-Vision-Instruct-bnb-4bit", # Can fit in a 80GB card!
"unsloth/Llama-3.2-90B-Vision-bnb-4bit",
"unsloth/Pixtral-12B-2409-bnb-4bit", # Pixtral fits in 16GB!
"unsloth/Pixtral-12B-Base-2409-bnb-4bit", # Pixtral base model
"unsloth/Qwen2-VL-2B-Instruct-bnb-4bit", # Qwen2 VL support
"unsloth/Qwen2-VL-7B-Instruct-bnb-4bit",
"unsloth/Qwen2-VL-72B-Instruct-bnb-4bit",
"unsloth/llava-v1.6-mistral-7b-hf-bnb-4bit", # Any Llava variant works!
"unsloth/llava-1.5-7b-hf-bnb-4bit",
] # More models at https://huggingface.co/unsloth
model, tokenizer = FastVisionModel.from_pretrained(
"unsloth/Llama-3.2-11B-Vision-Instruct",
load_in_4bit = True, # Use 4bit to reduce memory use. False for 16bit LoRA.
use_gradient_checkpointing = "unsloth", # True or "unsloth" for long context
)`
Error
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
🦥 Unsloth Zoo will now patch everything to make training faster!
SyntaxError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/unsloth/tokenizer_utils.py in
1060 try:
-> 1061 exec(trainer_text, globals())
1062 except:
SyntaxError: invalid syntax (, line 4)
During handling of the above exception, another exception occurred:
RuntimeError Traceback (most recent call last)
5 frames
/usr/local/lib/python3.11/dist-packages/unsloth/tokenizer_utils.py in
1061 exec(trainer_text, globals())
1062 except:
-> 1063 raise RuntimeError(f"Unsloth: Please file a bug report! Error patching {trainer_name}")
1064 exec(f"trl.trainer.{trainer_name} = Unsloth{trainer_name}", globals())
1065 pass
RuntimeError: Unsloth: Please file a bug report! Error patching SFTTrainer
Activity
ChagoLB commentedon Feb 13, 2025
Hello, i have the same issue! This happens to me when trying to import the necessary libraries to operate with the models:
From the first import of FastLanguageModel, this error appears:
In aditional info, this error raised today, i had no problems running the libraries yesterday
styalai commentedon Feb 13, 2025
Maybe try to install trl<1.15.0, I had the same error and it worked for me. There was the same problem here: #1698
kkailaasa commentedon Feb 13, 2025
Exactly how were you able to fix @styalai?
when running
!pip install "trl<0.15.0"followed by!pip install unsloth, getting this error:styalai commentedon Feb 13, 2025
I install all my libraries like this:
!pip install -q triton==3.1.0
!pip install -q trl==0.14.0
!pip install -q vllm==0.7.1
!pip install -q unsloth==2025.2.4 unsloth_zoo==2025.2.3
luochongqi commentedon Feb 13, 2025
@kkailaasa
pip install "trl<0.15.0". It will run successfully.You can try using conda and install the environment with the official conda command. After that, run this command in a new environment pip install "trl<0.15.0"
official conda command: https://docs.unsloth.ai/get-started/installing-+-updating/conda-install
ChagoLB commentedon Feb 13, 2025
It worked for me as well, thank you so much for the help!
i used this cell to run the instalations:
Not sure why the process runs like this, installing, uninstalling and then installing and upgrading unsloth, but i think i got those lines from one of their pre built notebooks (the lamma 8b v0.3 i think).
ChagoLB commentedon Feb 13, 2025
I had the same error, fixed it by using this line:
although pretty much every time i had to restart the runtime, then i would run smoothly
danielhanchen commentedon Feb 13, 2025
Apologies on the issue - I'm working on a fix asap
danielhanchen commentedon Feb 13, 2025
Just fixed - for now please use
TRL < 0.15.0- I updated all notebooks as well - so refresh them if you're using them. Ie do:I'm still trying to work on supporting the latest TRL 0.15.0, so it'll take a bit more time.
For GRPO runs, please use
"unsloth==2025.2.4"sopip install "unsloth==2025.2.4"Using
pip install unslothshould work since it'll use an old TRL versionzhangxuefeng commentedon Feb 14, 2025
Hi Daniel,
After doing this for fine-tuning job, I got new errors in inference phase:
AttributeError Traceback (most recent call last)
in <cell line: 0>()
53 ).to("cuda")
54
---> 55 outputs = model.generate(
56 input_ids = inputs, max_new_tokens = 64, use_cache = True, temperature = 1.5, min_p = 0.1
57 )
11 frames
/usr/local/lib/python3.11/dist-packages/unsloth/models/llama.py in LlamaModel_fast_forward(self, input_ids, causal_mask, attention_mask, position_ids, past_key_values, inputs_embeds, use_cache, output_attentions, output_hidden_states, return_dict, *args, **kwargs)
725 sliding_window = getattr(self.config, "sliding_window", None),
726 )
--> 727 attention_mask = attention_mask.to(torch.bool)
728 pass
729
AttributeError: 'NoneType' object has no attribute 'to'
kkailaasa commentedon Feb 14, 2025
thank you @luochongqi @styalai - I deleted and started up a fresh runtime, it worked.
@danielhanchen I also got the same error above as @zhangxuefeng just now
Thank you for providing the recent fix and also actively helping us sort these issues
Someone has also raised an independent issue here: #1704
[-]Error patching SFTTrainer[/-][+][FIXED] Error patching SFTTrainer[/+]danielhanchen commentedon Feb 14, 2025
@zhangxuefeng @kkailaasa Apologies - just added a fix! Please update Unsloth via
pip install --upgrade --no-deps --force-reinstall unsloth- or Colab / Kaggle will just need a refresh.Apologies this release has been quite annoying - hopefully this won't happen again - sorry again!
kkailaasa commentedon Feb 14, 2025
No problem @danielhanchen I'm testing out the latest version now.
zhangxuefeng commentedon Feb 14, 2025
Worked now !
Thanks !
udit-rawat commentedon Feb 14, 2025
Fix Colab notebook: use pip install unsloth (PyPI stable) instead of …