You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RuntimeError: Unsloth: The file 'llama.cpp/llama-quantize' or 'llama.cpp/quantize' does not exist #748
The below error occured while trying to convert model to gguf format.
I noticed that quantized folder resides in llama.cpp/examples/quantize
RuntimeError: Unsloth: The file 'llama.cpp/llama-quantize' or 'llama.cpp/quantize' does not exist.
But we expect this file to exist! Maybe the llama.cpp developers changed the name?
# Save to q4_k_m GGUF
if True: model.save_pretrained_gguf("model", tokenizer, quantization_method = "q4_k_m")
Reacted by scherbakovdmitri, Zhangy-ly, Rahul Madhav Upakare, Roman Kholiavko, Thomas Paul, leohan, Bryce, Weilu Jia, everythingisc00l, Chris Pang and 9 more
It looks we need to first run make on llama cpp folder manually, not sure why it stopped working in unsloth ggml-org/llama.cpp#8107
if you run make command in llama.cpp folder it will work
Reacted by Haowen-Ji, Charles Santos, Ilia Prokhorov, Manu Wickrama and Asankhaya Sharma
RuntimeError: Unsloth: The file 'llama.cpp/llama-quantize' or 'llama.cpp/quantize' does not exist.
But we expect this file to exist! Maybe the llama.cpp developers changed the name?
Wait so the issue persists? Are people using Colab / Runpod?
Hi Daniel,
Thank you for your response.
To clarify, the issue persists on my Ubuntu setup, although it seems to run without problems on Colab. Is there any other information you need to help diagnose the issue? plz tell me.
Ubuntu, NVIDIA V100, Driver Version: 535.146.02, CUDA Version: 12.1
cd llama.cpp git checkout b3345 git submodule update --init --recursive make clean make all -j git log -1
solved my situation. There are no llama-quantize and quantize file in the newest git source(08/07/2024). So, unslothai should install the specific version of llama.cpp to fix this issue. Thank you! ;)
It looks we need to first run make on llama cpp folder manually, not sure why it stopped working in unsloth ggerganov/llama.cpp#8107 if you run make command in llama.cpp folder it will work
Just noticed that it has been soled in #1375. Maybe the reason that I met this problem is because I manually paused the quantizing process just after it start.
Hello,
on my ubuntu server I have a new error due to export the model with llama.cpp. I copied llama-quantize to the main folder llama.cpp but now I get a new error when I try to export the model with: model.save_pretrained_gguf("mymodel", tokenizer, quantization_method = "q4_k_m", maximum_memory_usage=0.7)
line 824, in try_execute
raise RuntimeError(f"*** Unsloth: Failed compiling llama.cpp with {line}. Please report this ASAP!")
RuntimeError: *** Unsloth: Failed compiling llama.cpp with WARNING:hf-to-gguf:**************************************************************************************
. Please report this ASAP!
now im very confused because it works one and now I have really no idea how to fix this. But this is just for the phi4 model
Hello, on my ubuntu server I have a new error due to export the model with llama.cpp. I copied llama-quantize to the main folder llama.cpp but now I get a new error when I try to export the model with: model.save_pretrained_gguf("mymodel", tokenizer, quantization_method = "q4_k_m", maximum_memory_usage=0.7)
line 824, in try_execute raise RuntimeError(f"*** Unsloth: Failed compiling llama.cpp with {line}. Please report this ASAP!") RuntimeError: *** Unsloth: Failed compiling llama.cpp with WARNING:hf-to-gguf:************************************************************************************** . Please report this ASAP!
now im very confused because it works one and now I have really no idea how to fix this. But this is just for the phi4 model
Same here. I observe the same error when trying to convert a finetuned Phi-4 to GGUF. How to fix this?
Hello, on my ubuntu server I have a new error due to export the model with llama.cpp. I copied llama-quantize to the main folder llama.cpp but now I get a new error when I try to export the model with: model.save_pretrained_gguf("mymodel", tokenizer, quantization_method = "q4_k_m", maximum_memory_usage=0.7)
line 824, in try_execute raise RuntimeError(f"*** Unsloth: Failed compiling llama.cpp with {line}. Please report this ASAP!") RuntimeError: *** Unsloth: Failed compiling llama.cpp with WARNING:hf-to-gguf:************************************************************************************** . Please report this ASAP!
now im very confused because it works one and now I have really no idea how to fix this. But this is just for the phi4 model
I’m also unable to convert Phi-4 into GGUF in the same way. I was able to do it before.
Has anyone managed to solve this?
@mw-ctrl@rnckp
I've solved Phi-4 GGUF convering problem in my env.
Cause
During 4-bit training, the saved base_model_name becomes:
unsloth/phi-4-unsloth-bnb-4bit
Attempting to load the tokenizer from that name triggers the hf-to-gguf warning.
I also encountered the same error in the official Unsloth Phi-4 Colab notebook.
I also encountered this problem. After digging into the save.py, I see it checks for the llama-quantize executable in the environment path. If it is not there and convert_hf_to_gguf.py (included in the llama.cpp repo), then it clones the llama.cpp to the local project folder and tries to build it with CMake.
I let it clone, because I want the convert_hf_to_gguf.py from the repo, but I don't want to compile llama.cpp with CMake. So, I installed the pre-compiled binary (which includes the quantize executable) using Winget
One problem with the save.py is that when it references the cloned llama.cpp repo, it will build with CMake & override the quantize_location variable to None, which has already found in the PATH (from the get_executable method). So you have to make a minor changes to instruct it to use the quantize_location that has already found in the environment PATH.
# quantize_location = None # comment this line outifquantize_locationisNone: # add this line to skip detecting the quantize executable if it is already found by get_executable# quantize_location may already obtained using system path (get_executable), continue if it is not obtainedifos.path.exists("llama.cpp/quantize.exe"):
quantize_location="llama.cpp/quantize.exe"elifos.path.exists("llama.cpp/quantize"):
quantize_location="llama.cpp/quantize"elifos.path.exists("llama.cpp/llama-quantize.exe"):
quantize_location="llama.cpp/llama-quantize.exe"elifos.path.exists("llama.cpp/llama-quantize"):
quantize_location="llama.cpp/llama-quantize"elifos.path.exists("llama.cpp/build/bin/llama-quantize"):
quantize_location="llama.cpp/build/bin/llama-quantize"elifos.path.exists("llama.cpp/build/bin/quantize"):
quantize_location="llama.cpp/build/bin/quantize"else:
raiseRuntimeError(
"Unsloth: The file 'llama.cpp/llama-quantize' or `llama.cpp/quantize` does not exist.\n"\
"We've also double checked the building directory under 'llama.cpp/build/bin/'.\n"\
"But we expect this file to exist! Check if the file exists under llama.cpp and investigate the building process of llama.cpp (make/cmake)!"
)
pass
In this case, you will have both llama-quantize.exe & convert_hf_to_gguf.py to continue saving the model.
After that you will encounter another problem, it save.py will give you this error:
Unsloth: [2] Converting GGUF 16bit into q4_k_m. This might take 20 minutes...
'.' is not recognized as an internal or external command,
Follow the answer provided by @hoffor , it resolves the problem and saves the result model.
print(f"Unsloth: [2] Converting GGUF 16bit into {quant_method}. This might take 20 minutes...")
final_location=str((Path(model_directory) /f"unsloth.{quant_method.upper()}.gguf").absolute())
command=Noneifsys.platform=="win32": #check for windows environmentcommand=f"{Path(quantize_location).absolute()}{full_precision_location} "\
f"{final_location}{quant_method}{n_cpus}"else:
command=f"./{quantize_location}{full_precision_location} "\
f"{final_location}{quant_method}{n_cpus}"try_execute([command,], force_complete=True)
For vision/multimodal models, use tokenizer=processor
3- You can pass it one or several quant methods (as a list):
quantization_method = "q8_0"
or
quantization_method = ["q8_0", "q4_k_m"]
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 Modelfile for you that you can use to create your model in ollama using:
ollama create model_name -f ./Modelfile
5- Use push_to_hub_gguf if 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)
Activity
danielhanchen commentedon Jul 10, 2024
Weird I just tried it in the last hour and it works
scherbakovdmitri commentedon Jul 10, 2024
It looks we need to first run make on llama cpp folder manually, not sure why it stopped working in unsloth
ggml-org/llama.cpp#8107
if you run make command in llama.cpp folder it will work
danielhanchen commentedon Jul 12, 2024
Weird it stopped working? Hmm I shall try this in Colab and report back!
Zhangy-ly commentedon Jul 19, 2024
I have the same problem. Is there a solution now?
RuntimeError: Unsloth: The file 'llama.cpp/llama-quantize' or 'llama.cpp/quantize' does not exist.
But we expect this file to exist! Maybe the llama.cpp developers changed the name?
danielhanchen commentedon Jul 19, 2024
It should function - are you using Colab?
Zhangy-ly commentedon Jul 19, 2024
Well, mine is as follows:
NVIDIA V100
Driver Version: 535.146.02
CUDA Version: 12.1
I temporarily solved this problem by rolling back llama.cpp
cd llama.cppgit checkout b3345git submodule update --init --recursivemake cleanmake all -jgit log -1okoliechykwuka commentedon Jul 19, 2024
@danielhanchen Yes, I am using colab, but I am still having the same error.
danielhanchen commentedon Jul 20, 2024
Wait weird I just ran it with no errors in Colab - it's best to use our updated notebooks on our Github and start a fresh
Deluxer commentedon Jul 28, 2024
@Zhangy-ly That is an effective workaround.
theodufort commentedon Aug 1, 2024
To anyone having error while using those
bashcommands, use:!before each commanddanielhanchen commentedon Aug 2, 2024
Wait so the issue persists? Are people using Colab / Runpod?
Zhangy-ly commentedon Aug 2, 2024
Hi Daniel,
Thank you for your response.
To clarify, the issue persists on my Ubuntu setup, although it seems to run without problems on Colab. Is there any other information you need to help diagnose the issue? plz tell me.
Ubuntu, NVIDIA V100, Driver Version: 535.146.02, CUDA Version: 12.1
packages in environment:
Name Version
_libgcc_mutex 0.1
_openmp_mutex 5.1
accelerate 0.32.1
aiohttp 3.9.5
aiosignal 1.3.1
async-timeout 4.0.3
attrs 23.2.0
bitsandbytes 0.43.2
blas 1.0
brotli-python 1.0.9
bzip2 1.0.8
ca-certificates 2024.3.11
certifi 2024.7.4
charset-normalizer 2.0.4
cuda-cudart 12.1.105
cuda-cupti 12.1.105
cuda-libraries 12.1.0
cuda-nvrtc 12.1.105
cuda-nvtx 12.1.105
cuda-opencl 12.5.39
cuda-runtime 12.1.0
cuda-version 12.5
datasets 2.20.0
dill 0.3.8
docstring-parser 0.16
ffmpeg 4.3
filelock 3.13.1
freetype 2.12.1
frozenlist 1.4.1
fsspec 2024.2.0
gguf 0.9.1
gmp 6.2.1
gmpy2 2.1.2
gnutls 3.6.15
huggingface-hub 0.23.4
idna 3.7
intel-openmp 2023.1.0
jinja2 3.1.3
jpeg 9e
lame 3.100
lcms2 2.12
ld_impl_linux-64 2.38
lerc 3.0
libcublas 12.1.0.26
libcufft 11.0.2.4
libcufile 1.10.1.7
libcurand 10.3.6.82
libcusolver 11.4.4.55
libcusparse 12.0.2.55
libdeflate 1.17
libffi 3.4.4
libgcc-ng 11.2.0
libgomp 11.2.0
libiconv 1.16
libidn2 2.3.4
libjpeg-turbo 2.0.0
libnpp 12.0.2.50
libnvjitlink 12.1.105
libnvjpeg 12.1.1.14
libpng 1.6.39
libstdcxx-ng 11.2.0
libtasn1 4.19.0
libtiff 4.5.1
libunistring 0.9.10
libuuid 1.41.5
libwebp-base 1.3.2
llvm-openmp 14.0.6
lz4-c 1.9.4
markdown-it-py 3.0.0
markupsafe 2.1.5
mdurl 0.1.2
mkl 2023.1.0
mkl-service 2.4.0
mkl_fft 1.3.8
mkl_random 1.2.4
mpc 1.1.0
mpfr 4.0.2
mpmath 1.3.0
multidict 6.0.5
multiprocess 0.70.16
ncurses 6.4
nettle 3.7.3
networkx 3.2.1
numpy 1.26.4
numpy-base 1.26.4
nvidia-cublas-cu12 12.1.3.1
nvidia-cuda-cupti-cu12 12.1.105
nvidia-cuda-nvrtc-cu12 12.1.105
nvidia-cuda-runtime-cu12 12.1.105
nvidia-cudnn-cu12 8.9.2.26
nvidia-cufft-cu12 11.0.2.54
nvidia-curand-cu12 10.3.2.106
nvidia-cusolver-cu12 11.4.5.107
nvidia-cusparse-cu12 12.1.0.106
nvidia-nccl-cu12 2.19.3
nvidia-nvjitlink-cu12 12.1.105
nvidia-nvtx-cu12 12.1.105
openh264 2.1.1
openjpeg 2.4.0
openssl 3.0.14
packaging 24.1
pandas 2.2.2
peft 0.11.1
pillow 10.3.0
pip 24.0
protobuf 3.20.3
psutil 6.0.0
pyarrow 16.1.0
pyarrow-hotfix 0.6
pygments 2.18.0
pysocks 1.7.1
python 3.10.13
python-dateutil 2.9.0.post0
pytorch-cuda 12.1
pytorch-mutex 1.0
pytz 2024.1
pyyaml 6.0.1
readline 8.2
regex 2024.5.15
requests 2.32.2
rich 13.7.1
safetensors 0.4.3
sentencepiece 0.2.0
setuptools 69.5.1
shtab 1.7.1
six 1.16.0
sqlite 3.45.3
sympy 1.12
tbb 2021.8.0
tk 8.6.14
tokenizers 0.19.1
torch 2.2.0+cu121
torchaudio 2.2.0
torchvision 0.17.0
tqdm 4.66.4
transformers 4.43.1
triton 2.2.0
trl 0.8.6
typing-extensions 4.9.0
tyro 0.8.5
tzdata 2024.1
unsloth 2024.7
urllib3 2.2.2
wheel 0.43.0
xformers 0.0.24
xxhash 3.4.1
xz 5.4.6
yaml 0.2.5
yarl 1.9.4
zlib 1.2.13
zstd 1.5.5
jeehunseo commentedon Aug 7, 2024
solved my situation. There are no llama-quantize and quantize file in the newest git source(08/07/2024). So, unslothai should install the specific version of llama.cpp to fix this issue. Thank you! ;)
thyarles commentedon Aug 13, 2024
Same problem here. This tip solved the issue.
14 remaining items
hwpoison commentedon Dec 25, 2024
It works for me.
In Collab env i used
Then i copied the executable to /content/llama.cpp directory with cp then i re-ran the celd.
fumiama commentedon Jan 27, 2025
Thanks. Same problem, following this instruction and solved. Seems that the llama.cpp compiling logic of unsloth should be renewed.
fumiama commentedon Jan 27, 2025
Just noticed that it has been soled in #1375. Maybe the reason that I met this problem is because I manually paused the quantizing process just after it start.
Deluxer commentedon Jan 29, 2025
Summary: Just copy
llama.cpp/build/bin/llama-quantizetollama.cpp/, then try again.everythingisc00l commentedon Feb 9, 2025
UPD 10.02.2025:
This is my recept for fix this bug ONLY FOR WINDOWS 11. (I'm using Windows 11 with WSL Ubuntu)
if you wanna full solution check my fix: #1649
llama-quantize to llama-quantize.exequantize_location = None if os.path.exists("llama.cpp/quantize.exe"): quantize_location = "llama.cpp/quantize.exe" elif os.path.exists("llama.cpp/llama-quantize.exe"): quantize_location = "llama.cpp/llama-quantize.exe"and this working for me.
mw-ctrl commentedon Mar 12, 2025
Hello,
on my ubuntu server I have a new error due to export the model with llama.cpp. I copied llama-quantize to the main folder llama.cpp but now I get a new error when I try to export the model with: model.save_pretrained_gguf("mymodel", tokenizer, quantization_method = "q4_k_m", maximum_memory_usage=0.7)
line 824, in try_execute
raise RuntimeError(f"*** Unsloth: Failed compiling llama.cpp with {line}. Please report this ASAP!")
RuntimeError: *** Unsloth: Failed compiling llama.cpp with WARNING:hf-to-gguf:**************************************************************************************
. Please report this ASAP!
now im very confused because it works one and now I have really no idea how to fix this. But this is just for the phi4 model
hoffor commentedon Mar 25, 2025
SUPER DUMB EASY WORKAROUND FOR WINDOWS USERS:
just move the binaries from the latest llama build .zip into the base llama.cpp folder. don't need to build anything yourself
get em from here: https://github.com/ggml-org/llama.cpp/releases
i used llama-b4951-bin-win-cuda-cu12.4-x64.zip (since i'm using cuda toolkit 12.4) and it works just fine
also in "Lib\site-packages\unsloth\save.py" i had to change:
to:
command = f"{Path(quantize_location).absolute()} {full_precision_location} {final_location} {quant_method} {n_cpus}"or else it'll tell me
'.' is not recognized as an internal or external command, operable program or batch file.edit: btw i made a full on script to just set everything up for unsloth from scratch if you're ever feeling stuck (comes with an example notebook and dataset too): https://github.com/hoffor/llms-are-dumb
rnckp commentedon Apr 12, 2025
Same here. I observe the same error when trying to convert a finetuned Phi-4 to GGUF. How to fix this?
mw-ctrl commentedon Apr 12, 2025
@rnckp To resolve a similar issue in the past, I incorporated the export directly into the fine-tuning process using this code:"
trainer_stats = unsloth_train(trainer)
trainer.save_model()
model.save_pretrained("gguf", tokenizer, quantization_method="q4_k_m")
Fredrik-C commentedon May 5, 2025
My savior!!!
After fiddeling for hours with make, cmake, g++ etc I came to the conclusion to use the precompiled packages and got stuck on the "." error.
GAH... I was getting passed the '.' error by the save.py mod, just to get another error:
akimasax commentedon May 29, 2025
I’m also unable to convert Phi-4 into GGUF in the same way. I was able to do it before.
Has anyone managed to solve this?
akimasax commentedon Jun 4, 2025
@mw-ctrl @rnckp
I've solved Phi-4 GGUF convering problem in my env.
Cause
During 4-bit training, the saved base_model_name becomes:
Attempting to load the tokenizer from that name triggers the hf-to-gguf warning.
I also encountered the same error in the official Unsloth Phi-4 Colab notebook.
Solution
unsloth/Phi-4:This separation works for me.
The other llama.cpp–related errors were resolved using the steps at the following link, and I was able to convert the Phi-4 model to GGUF:https://github.com/osllmai/llama.cpp/blob/main/docs/build.md
zwb1988 commentedon Sep 20, 2025
I also encountered this problem. After digging into the save.py, I see it checks for the llama-quantize executable in the environment path. If it is not there and convert_hf_to_gguf.py (included in the llama.cpp repo), then it clones the llama.cpp to the local project folder and tries to build it with CMake.
I let it clone, because I want the convert_hf_to_gguf.py from the repo, but I don't want to compile llama.cpp with CMake. So, I installed the pre-compiled binary (which includes the quantize executable) using Winget
In this case, you will have both llama-quantize.exe & convert_hf_to_gguf.py to continue saving the model.
Follow the answer provided by @hoffor , it resolves the problem and saves the result model.
rolandtannous commentedon Oct 15, 2025
@AleefBilal @Antonytm @ChernXiangyu @ColtDS @Deluxer @FotieMConstant @Fredrik-C @Govindraj07 @Han-SeungJun @Haowen-Ji @Justin22122002 @LeMoussel @MisterSoandSo @OscarArroyoVega @Seynro @XiaomoWu @Zhangy-ly @aghac19 @akimasax @alarv @amygbAI @andthattoo @beiwilliam @brlin-tw @brycelund @chrispangg @codelion @demensdeum @devinwang @divmgl @ericbanzuzi @everythingisc00l @fumiama @gaoshan0007 @goerkemballmueller @hamishdickson @hideaki @hoffor @huan161299 @hwpoison @ikramMc @jainpradeep @jeehunseo @jhlu2019 @josemgmz @jrsynow @karman103 @kenkeiras @kholiavko-roman @kikiyu @kkk112 @lastrei @lideyang @manu-one @maziyarpanahi @mik8142 @mjbatalha @mrtpk @mw-ctrl @nokey93 @okoliechykwuka @optix2000 @ozziek @phoenix1028 @pranavs1997 @prcvoldermort @rektyyy @rnckp @rorubyy @rosameliacarioni @sahajre @scherbakovdmitri @serena97 @singlerock @skippetr @smirki @stevechk @theodufort @thinhlpg @throttlekitty @thyarles @topikuq @trash-fish @tuananhit1612 @variable @whisper-bye @yangyifei-gogogo @yuxiaojian @zhuqifan @zwb1988 @zyx20030325
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 how this goes for you.
Thanks!