Repository navigation
Closed
Labels
fixedFixed!
Description
Hey,
Congrat for the work!
I have a vision FT but when attempting to download the GGUF for Ollama usage, it gives me this exception:
Loading checkpoint shards: 100%|██████████| 2/2 [00:03<00:00, 1.57s/it]%| | 0/2 [00:00<?, ?it/s]
2025-01-05 04:09:07,810 - ERROR - STDERR: max_steps is given, it will override any value given in num_train_epochs
2025-01-05 04:09:07,810 - ERROR - STDERR: ==((====))== Unsloth - 2x faster free finetuning | Num GPUs = 1
2025-01-05 04:09:07,810 - ERROR - STDERR: \\ /| Num examples = 54 | Num Epochs = 1
2025-01-05 04:09:07,820 - ERROR - STDERR: O^O/ \_/ \ Batch size per device = 2 | Gradient Accumulation steps = 4
2025-01-05 04:09:07,820 - ERROR - STDERR: \ / Total batch size = 8 | Total steps = 5
2025-01-05 04:09:07,824 - ERROR - STDERR: "-____-" Number of trainable parameters = 16,793,600
2025-01-05 04:09:07,826 - ERROR - STDERR: 🦥 Unsloth needs about 1-3 minutes to load everything - please wait!
100%|██████████| 5/5 [01:20<00:00, 16.08s/it] | 0/5 [00:00<?, ?it/s]
2025-01-05 04:09:07,829 - ERROR - STDERR: Traceback (most recent call last):
2025-01-05 04:09:07,832 - ERROR - STDERR: File "/home/Ubuntu/finetune.py", line 145, in <module>
2025-01-05 04:09:07,833 - ERROR - STDERR: model.save_pretrained_gguf(MODEL_NAME, tokenizer)
2025-01-05 04:09:07,835 - ERROR - STDERR: File "/home/Ubuntu/miniconda3/lib/python3.12/site-packages/unsloth/save.py", line 2238, in not_implemented_save
2025-01-05 04:09:07,836 - ERROR - STDERR: raise NotImplementedError("Unsloth: Sorry GGUF is currently not supported for vision models!")
2025-01-05 04:09:07,837 - ERROR - STDERR: NotImplementedError: Unsloth: Sorry GGUF is currently not supported for vision models!
2025-01-05 04:09:07,840 - ERROR - Command failed with non-zero exit status: bash -l -c 'eval "$(~/miniconda3/bin/conda shell.bash hook)" && conda activate && python3 finetune.py'Is this being currently developed? Or is there another possible way of using my FT LLM models in Ollama?
I followed the steps from the Docs:
...
trainer_stats = trainer.train()
model.save_pretrained(MODEL_NAME) # Local saving
tokenizer.save_pretrained(MODEL_NAME)
# model.push_to_hub("your_name/lora_model", token = "...") # Online saving
# tokenizer.push_to_hub("your_name/lora_model", token = "...") # Online saving
used_memory = round(torch.cuda.max_memory_reserved()/1024/1024/1024, 3)
used_memory_for_lora = round(used_memory - start_gpu_memory, 3)
used_percentage = round(used_memory/max_memory*100, 3)
lora_percentage = round(used_memory_for_lora/max_memory*100,3)
print(f"{trainer_stats.metrics['train_runtime']} seconds used for training.")
print(f"Peak reserved memory = {used_memory} GB.")
print(f"Peak reserved memory for training = {used_memory_for_lora} GB.")
print(f"Peak reserved memory % of max memory = {used_percentage} %.")
print(f"Peak reserved memory for training % of max memory = {lora_percentage} %.")
# Save model in GGUF format
model.save_pretrained_gguf(MODEL_NAME, tokenizer)Reacted by weoieoeo, Vishwa Bhushan Dewangan, Ejektaflex, Valentin Fröhlich and Sergio García Arrojo
Metadata
Metadata
Assignees
Labels
fixedFixed!
Activity
danielhanchen commentedon Jan 10, 2025
Sorry on the delay - I'm planning to add GGUF support in the coming days!
SecchiAlessandro commentedon Feb 3, 2025
Is it resolved?
fitlemon commentedon Feb 22, 2025
I want to use finetuned vision models on CPU. Converting to GGUF doesn't work. What alternatives are there to use models on CPU?
just4give commentedon Mar 16, 2025
wondering if there is any update on this? I am trying to convert FT Vision model to GGUF for ollama and experiencing the same issue above.
Is there any alternative anyone got working? Looks like gguf is not supported by llama.cpp for llama vision models either.
weoieoeo commentedon Mar 28, 2025
May I ask once again if this is currently being addressed?
Mistral Small 3.1 and Qwen2.5_32B seem very promising. I can fine-tune them on a dedicated PC, but for inference, I need GGUF versions to partially offload workloads onto the CPU, as not all inference PCs have 24GB of VRAM.
Thank you in advance!
phiwi commentedon Mar 31, 2025
Any news on this?
AbhayaHanuma commentedon Apr 19, 2025
Facing the same issue. Any luck for anyone?
JackCro02 commentedon Apr 27, 2025
Same issue.
unsloth (versions unsloth-2025.3.19 and unsloth-2025.4.1) will not save gguf using the commands listed here:
https://docs.unsloth.ai/basics/running-and-saving-models/saving-to-gguf
Any luck anyone?
karltrout commentedon May 4, 2025
Having the same issue. Following.
kaiu85 commentedon May 6, 2025
I'm experiencing the same issue when trying to save a fine-tuned version of Mistral-3.1-Small-Instruct-2503.
weoieoeo commentedon May 7, 2025
Hi kaiu85,
this may be offtopic, but could you share a code snippet on how you finetuned Mistral 3.1 small? What is the structure of your vision dataset and how did you structure the instruction that includes prompt (1), image (2) and the desired answer (3)?
Is it comparable to finetuning lama3.2_11B_Vision? Like here:
Many thanks!
sambhavnoobcoder commentedon May 8, 2025
saw this as a recurrent issue , for all the folks out there facing this , could you lay down a simple reproducer for me? you can try out this branch : https://github.com/sambhavnoobcoder/unsloth/tree/GGUF-Save . wrote some basic tests myself , it seems to pass my version and understanding of the tests , i can look into this more clearly if any of you could lay down a clearer reproducer for the same . thanks .
kaiu85 commentedon May 8, 2025
Thank you very much. This is a very basic training notebook, which reproduces my issue (completely based on your great tutorial notebooks): https://colab.research.google.com/drive/1a4lW9H-9PN_nhjjh9NNy0I_QhZk6XNMn?usp=sharing
sambhavnoobcoder commentedon May 8, 2025
thank you very much for the reproducer @kaiu85 . i'll aim to use your colab as a test for my branch , check out if it solves the issue for you and this reproducer , use this as a parameter and report back once successful on the same .
sambhavnoobcoder commentedon May 9, 2025
okay cool , so i think the fix is here @kaiu85 , i tried out your reproducer , modified it slightly with a different model (slightly smaller ) and tested with this script here , a slight modification of your original reproducer . this seems to be able to run and save everything successfully . Here is a reference of the screenshot of the colab where i tested this out :
Do tell me if there is anything else you'd like to point out , i would look at that as well .
also @danielhanchen , do you need this fixed in the project ? just confirming , because if you do , i'll raise a PR for the same . Awaiting your confirmation .
just4give commentedon Jul 8, 2025
@sambhavnoobcoder can you please help understand what you did to successfully convert to gguf? I am using llama 3.2 11b vision instruct.
chrisjohnson00 commentedon Jul 28, 2025
I used a slightly modified version of your script with the following mods, but was unable to get anything to save successfully:
vision_model_save_pretrained_ggufreferences as that seems to not be part ofunsloth.saveanymoreuse_flash_attention_2=False,as that seemed to cause all models to fail loading("unsloth/gemma-3n-E2B-it", True, False)tomodels_to_tryas this is the model I'm playing withThis resulted in:
Switching
quantization_methodforquantization_typein the arguments ofmode.save_pretrained_gguf(as suggested in other issues), resulted inAdding any value, string or list of strings to
quantization_method, for examplequantization_method=['fast_quantized'], provides me with:Using
unsloth==2025.7.8in this testchrisjohnson00 commentedon Jul 29, 2025
I'm fine tuning
unsloth/gemma-3n-E2B-itand when I get to:I debug traced it to the
save_to_gguf_genericmethod call, andquantization_methodis passing in asGemma3nProcessortype, which causes it to fall into theTypeErrorclause.I'll continue looking into this, but am going on vacation after tomorrow, so can only give it another day of troubleshooting before I will likely move on to other projects for bit.
Guedd commentedon Aug 18, 2025
Hi everyone, i think this link will help you to solve the problem, just folow the instructions https://docs.unsloth.ai/basics/tutorials-how-to-fine-tune-and-run-llms/tutorial-how-to-finetune-llama-3-and-use-in-ollama, and use thier colab notebook https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Llama3_(8B)-Ollama.ipynb#scrollTo=95_Nn-89DhsL
chrisjohnson00 commentedon Aug 18, 2025
I followed the guides to get where I am. I'm not running with google colab, using my own environments. The colab notebooks are great, hard to convert to native Python, but are either missing some details that the colab env brings, or are incomplete.
Guedd commentedon Aug 25, 2025
Hi, I have switched from using Unsloth's Built-in functions to manually converting the model. First, use the save_pretrained_merged function after finishing training, or loading a model with LORA weights and merging it using the same function. After merging, follow the manual steps to export the GGUF file using llama.ccp: https://github.com/unslothai/unsloth/wiki#manually-saving-to-gguf
After the exporting, you have to create and edit the "modelfile", it's different from a model to another, depends on the starts, eos, end tokens, and special tokens, model Imstruction, and other, you can check some youtube video to learn, or give it to ChatGPT, or Gemini they will take care of the file
Guedd commentedon Aug 25, 2025
Vsiom Model uses a GPU in the first place. If you are willing to use it for text-to-text conversation, then it wouldn't require a GPU, but for images, you have to use a GPU. After converting, push the model to your ollama Hub, or you can save it locally and use it with ollama as well.
chrisjohnson00 commentedon Aug 25, 2025
Thanks! Will try. I, understandably, only had one
save_pretrained_mergedcall, so check this out. It may be days/weeks before I get back to this though, so no one hold your breath on my response!rolandtannous commentedon Oct 15, 2025
@Any-Winter-4079 @FierceHero @Guedd @JackCro02 @JustinYuann @SecchiAlessandro @SergioRubio01 @chrisjohnson00 @ejektaflex @fitlemon @juanqui @just4give @kaiu85 @karltrout @mikeknapp @phiwi @sambhavnoobcoder @valentinfrlch @vishwa30 @weoieoeo
We just pushed a major fix for llamacpp integration.
1- Please make sure to update your local install of unsloth
If you're using a notebook on kaggle or colab, it should pull the latest version automatically.
2- You can now use
save_pretrained_ggufto quantize and save to GGUF format:For vision/multimodal models, use
tokenizer=processor3- You can pass it one or several quant methods (as a list):
or
We support all the quants mentioned in this page except the iq variants.
4- If the model is supported by Ollama, it will now also automatically create a
Modelfilefor you that you can use to create your model in ollama using:5- Use
push_to_hub_ggufif you want to convert to gguf and push to Huggingface Hub instead.6- Should work for all models supported by unsloth and ollama.
7- It now fully supports linux debian and RPM variants. We are still testing windows (if someone has a windows machine and is on our discord channel ping me to help debug)
Let me know.
Thanks!
rolandtannous commentedon Oct 23, 2025
Will be closing this for now as the issue has been resolved. Please make sure to follow the instructions given in my last response.
Meanwhile , please feel free to respond if you're still having any issues.
Thank you