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
Unsloth keeps using my CPU for inference. and I found the reason and solution! #5941
A Studio update/installer rewrote the backend bootstrap and restored the default path logic.
On startup, Studio preferred a stale CPU-only llama-server path instead of the valid CUDA build.
Result: training works, but GGUF inference falls back to CPU forever.
Suggested fix for Unsloth:
Prefer a verified CUDA-capable binary when multiple local llama-server.exe builds exist.
On Windows, during startup, probe candidate binaries with --list-devices and reject ones that return no CUDA devices when NVIDIA/CUDA is present.
Do not silently bind to:
...\build\bin\Release\llama-server.exe
if a working CUDA build exists elsewhere in the same tree.
4. Persist the chosen backend path across Studio updates instead of resetting to default bootstrap logic.
5. If Studio detects NVIDIA + CUDA training support but inference binary is CPU-only, show a hard warning in UI instead of silently using CPU.
hi @MightyXdash i made a fix in #5969 if you could try pulling the branch and seeing if it fixes your issue and commenting the results that would be great
The underlying problem here (Windows + NVIDIA resolving to the CPU llama-server build) has been fixed in main, just through a different approach than the one originally proposed.
Could you update to the latest main and confirm inference picks up your RTX 5070 now? A fresh install is best so the new prebuilt selection runs. If you still see the "no usable GPU found" warning on inference, drop the install/selection log here and we'll reopen.
Thanks for the detailed writeup, it lined up exactly with what got fixed.
Last week I was meddling with the same issue, trying to run Gemma 4 12B but always having the inference land on the CPU. Then I rebuilt llama.cpp manually with CUDA and the same thing was happening. So I tried running literally the same build directly with different arguments (explicitly stating gpu layers and batch size) and it worked, getting full GPU utilization:
Today I completely reinstalled unsloth studio to see if it's gonna work on its own now and nope, most of the inference still gets thrown on the CPU. GPU utilization hanging around 30-40%. Running on CUDA toolkit 13.3, RTX 2070 Super Max Q. It built llama.cpp from source during install and no errors were found there.
I think it's genuinely just the default llama-server arguments when running through unsloth that are causing the issue now, maybe it's because gpu layers aren't mentioned at all? These are the parameters it runs with through unsloth: {"timestamp": "2026-06-13T11:37:16.707939Z", "level": "info", "event": "Starting llama-server: C:\\Users\\pavle\\.unsloth\\llama.cpp\\build\\bin\\Release\\llama-server.exe -m C:\\Users\\pavle\\.cache\\huggingface\\hub\\models--unsloth--gemma-4-12b-it-GGUF\\snapshots\\3249fa54d5efa384afc552cc6700ad091efd5c39\\gemma-4-12b-it-UD-Q4_K_XL.gguf --port 4763 -c 4096 --parallel 1 --flash-attn on --no-context-shift --fit on --threads -1 --jinja --model-draft C:\\Users\\pavle\\.cache\\huggingface\\hub\\models--unsloth--gemma-4-12b-it-GGUF\\snapshots\\3249fa54d5efa384afc552cc6700ad091efd5c39\\mtp-gemma-4-12b-it.gguf --spec-type draft-mtp --spec-draft-n-max 2 --chat-template-file C:\\Users\\pavle\\AppData\\Local\\Temp\\unsloth_chat_template_vnjbl4j4.jinja --chat-template-kwargs {\"enable_thinking\": true, \"preserve_thinking\": false} --mmproj C:\\Users\\pavle\\.cache\\huggingface\\hub\\models--unsloth--gemma-4-12b-it-GGUF\\snapshots\\3249fa54d5efa384afc552cc6700ad091efd5c39\\mmproj-F16.gguf"}
Edit: I reran the automatically built llama-server again, with the custom command above and once again got full GPU utilization.
Last week I was meddling with the same issue, trying to run Gemma 4 12B but always having the inference land on the CPU. Then I rebuilt llama.cpp manually with CUDA and the same thing was happening. So I tried running literally the same build directly with different arguments (explicitly stating gpu layers and batch size) and it worked, getting full GPU utilization:
Today I completely reinstalled unsloth studio to see if it's gonna work on its own now and nope, most of the inference still gets thrown on the CPU. GPU utilization hanging around 30-40%. Running on CUDA toolkit 13.3, RTX 2070 Super Max Q. It built llama.cpp from source during install and no errors were found there.
I think it's genuinely just the default llama-server arguments when running through unsloth that are causing the issue now, maybe it's because gpu layers aren't mentioned at all? These are the parameters it runs with through unsloth: {"timestamp": "2026-06-13T11:37:16.707939Z", "level": "info", "event": "Starting llama-server: C:\\Users\\pavle\\.unsloth\\llama.cpp\\build\\bin\\Release\\llama-server.exe -m C:\\Users\\pavle\\.cache\\huggingface\\hub\\models--unsloth--gemma-4-12b-it-GGUF\\snapshots\\3249fa54d5efa384afc552cc6700ad091efd5c39\\gemma-4-12b-it-UD-Q4_K_XL.gguf --port 4763 -c 4096 --parallel 1 --flash-attn on --no-context-shift --fit on --threads -1 --jinja --model-draft C:\\Users\\pavle\\.cache\\huggingface\\hub\\models--unsloth--gemma-4-12b-it-GGUF\\snapshots\\3249fa54d5efa384afc552cc6700ad091efd5c39\\mtp-gemma-4-12b-it.gguf --spec-type draft-mtp --spec-draft-n-max 2 --chat-template-file C:\\Users\\pavle\\AppData\\Local\\Temp\\unsloth_chat_template_vnjbl4j4.jinja --chat-template-kwargs {\"enable_thinking\": true, \"preserve_thinking\": false} --mmproj C:\\Users\\pavle\\.cache\\huggingface\\hub\\models--unsloth--gemma-4-12b-it-GGUF\\snapshots\\3249fa54d5efa384afc552cc6700ad091efd5c39\\mmproj-F16.gguf"}
Edit: I reran the automatically built llama-server again, with the custom command above and once again got full GPU utilization.
I am experiencing this in the Docker version in fedora 44 with a rtx 3050. training uses the GPU just fine, but it refuses to do inference with the GPU.
Alright so I clean installed the latest version of unsloth once again, this time on my RTX 2080 Super machine. The build for llama.cpp was correct, it definitely had CUDA support. I once again tried running gemma4 12B, and once again my GPU utilization was low. So I figured I'd try with a much smaller model, like gemma4 2B, which hovered around 66% GPU utilization.
Comparing the logs, it's clear that the main difference is that when running the 2B model, the -ngl -1 parameter is added, offloading all layers to the GPU, meanwhile for the 12B model it's completely absent. Realistically, it could offload at least something but it completely gives up instead. So I tried forcing the -ngl -1 parameter with unsloth studio run --model unsloth/gemma-4-12B-it-qat-GGUF -ngl -1 and got the same behavior. Then I tried the same with -ngl 999 and finally got 100% GPU utilization, and performance ~20 tok/s.
So really I think unsloth is just being too conservative in estimating what can and cannot fit on the GPU when calculating gpu layers. It's true that gemma4 12B on an 8GB card is a tight fit, but the problem here is not that it's not loading into memory (it is, with no problems at all), it's that inference is not running on the GPU at all. I don't know how unsloth chooses these parameters, but it would either have to be tweaked to be a little more lenient, or even better I wish we had some interface that would allow us to manually set the desired parameters (similarly to how we can change the context window in the sidebar). I don't know, maybe I'm too ambitious trying to run this model in the first place, but such a feature would surely come in handy when fine tuning and tinkering.
As for the builds of llama.cpp, it's been a while since I've had issues with them. The last few times I got the correct CUDA build instead of the CPU-only one.
Fixed! Sorry on the delay. When a llama.cpp folder had a CPU-only build next to a CUDA build-cuda, Studio always took the first one it found, so inference ran on the CPU while training used the GPU. Since #11005 Studio checks which builds actually ship a GPU backend and prefers the one your GPU can run, and since #8812 it warns in the UI when a model loads with no layers (or only some) on the GPU. If you set LLAMA_SERVER_PATH yourself, that exact binary is still used as-is, so point it at the CUDA build or remove it.
@Pavlogal what you saw is a different thing: a 12B with the vision projector and MTP draft does not fit in 8 GB, so llama.cpp's own fitter keeps only part of the model on the GPU. Since #6414 you can override that in the model settings under Advanced > GPU Memory > Manual, then set GPU Layers (the same as --gpu-layers). On Windows a value above what fits can still run because the NVIDIA driver spills to system RAM.
@mr-pepe69 if Docker still runs inference on the CPU after updating, please open a new issue with the Starting llama-server line and the llama-server startup log.
To update: Unsloth Desktop will have an update banner. For Studio, use unsloth studio update. For Docker, use docker exec <container> unsloth-studio-update. Reopen if it still happens.
Activity
LeoBorcherding commentedon Jun 5, 2026
hi @MightyXdash i made a fix in #5969 if you could try pulling the branch and seeing if it fixes your issue and commenting the results that would be great
LeoBorcherding commentedon Jun 12, 2026
The underlying problem here (Windows + NVIDIA resolving to the CPU llama-server build) has been fixed in main, just through a different approach than the one originally proposed.
Two PRs cover it:
Could you update to the latest main and confirm inference picks up your RTX 5070 now? A fresh install is best so the new prebuilt selection runs. If you still see the "no usable GPU found" warning on inference, drop the install/selection log here and we'll reopen.
Thanks for the detailed writeup, it lined up exactly with what got fixed.
Pavlogal commentedon Jun 13, 2026
Last week I was meddling with the same issue, trying to run Gemma 4 12B but always having the inference land on the CPU. Then I rebuilt llama.cpp manually with CUDA and the same thing was happening. So I tried running literally the same build directly with different arguments (explicitly stating gpu layers and batch size) and it worked, getting full GPU utilization:
C:\Users\pavle\.unsloth\llama.cpp\build\bin\Release\llama-server.exe -m C:\Users\pavle\.cache\huggingface\hub\models--unsloth--gemma-4-12b-it-GGUF\snapshots\3f09de26549e6d7ea54f1b83755149f840fcd333\gemma-4-12b-it-UD-Q4_K_XL.gguf --port 1627 -c 10000 --parallel 1 --flash-attn on --no-context-shift --fit on --threads -1 --gpu-layers 999 --batch-size 512 --jinja --spec-default --chat-template-kwargs '{\"enable_thinking\":true}' --mmproj C:\Users\pavle\.cache\huggingface\hub\models--unsloth--gemma-4-12b-it-GGUF\snapshots\3f09de26549e6d7ea54f1b83755149f840fcd333\mmproj-F16.ggufToday I completely reinstalled unsloth studio to see if it's gonna work on its own now and nope, most of the inference still gets thrown on the CPU. GPU utilization hanging around 30-40%. Running on CUDA toolkit 13.3, RTX 2070 Super Max Q. It built llama.cpp from source during install and no errors were found there.
I think it's genuinely just the default llama-server arguments when running through unsloth that are causing the issue now, maybe it's because gpu layers aren't mentioned at all? These are the parameters it runs with through unsloth:
{"timestamp": "2026-06-13T11:37:16.707939Z", "level": "info", "event": "Starting llama-server: C:\\Users\\pavle\\.unsloth\\llama.cpp\\build\\bin\\Release\\llama-server.exe -m C:\\Users\\pavle\\.cache\\huggingface\\hub\\models--unsloth--gemma-4-12b-it-GGUF\\snapshots\\3249fa54d5efa384afc552cc6700ad091efd5c39\\gemma-4-12b-it-UD-Q4_K_XL.gguf --port 4763 -c 4096 --parallel 1 --flash-attn on --no-context-shift --fit on --threads -1 --jinja --model-draft C:\\Users\\pavle\\.cache\\huggingface\\hub\\models--unsloth--gemma-4-12b-it-GGUF\\snapshots\\3249fa54d5efa384afc552cc6700ad091efd5c39\\mtp-gemma-4-12b-it.gguf --spec-type draft-mtp --spec-draft-n-max 2 --chat-template-file C:\\Users\\pavle\\AppData\\Local\\Temp\\unsloth_chat_template_vnjbl4j4.jinja --chat-template-kwargs {\"enable_thinking\": true, \"preserve_thinking\": false} --mmproj C:\\Users\\pavle\\.cache\\huggingface\\hub\\models--unsloth--gemma-4-12b-it-GGUF\\snapshots\\3249fa54d5efa384afc552cc6700ad091efd5c39\\mmproj-F16.gguf"}Edit: I reran the automatically built llama-server again, with the custom command above and once again got full GPU utilization.
mithulaartigala commentedon Jun 16, 2026
I had the same issue btw (AGAIN!!)
mithulaartigala commentedon Jun 16, 2026
i didnt mean to close it
mr-pepe69 commentedon Jun 22, 2026
I am experiencing this in the Docker version in fedora 44 with a rtx 3050. training uses the GPU just fine, but it refuses to do inference with the GPU.
Pavlogal commentedon Jul 5, 2026
Alright so I clean installed the latest version of unsloth once again, this time on my RTX 2080 Super machine. The build for llama.cpp was correct, it definitely had CUDA support. I once again tried running gemma4 12B, and once again my GPU utilization was low. So I figured I'd try with a much smaller model, like gemma4 2B, which hovered around 66% GPU utilization.
12B logs:
2B logs:
Comparing the logs, it's clear that the main difference is that when running the 2B model, the
-ngl -1parameter is added, offloading all layers to the GPU, meanwhile for the 12B model it's completely absent. Realistically, it could offload at least something but it completely gives up instead. So I tried forcing the-ngl -1parameter withunsloth studio run --model unsloth/gemma-4-12B-it-qat-GGUF -ngl -1and got the same behavior. Then I tried the same with-ngl 999and finally got 100% GPU utilization, and performance ~20 tok/s.So really I think unsloth is just being too conservative in estimating what can and cannot fit on the GPU when calculating gpu layers. It's true that gemma4 12B on an 8GB card is a tight fit, but the problem here is not that it's not loading into memory (it is, with no problems at all), it's that inference is not running on the GPU at all. I don't know how unsloth chooses these parameters, but it would either have to be tweaked to be a little more lenient, or even better I wish we had some interface that would allow us to manually set the desired parameters (similarly to how we can change the context window in the sidebar). I don't know, maybe I'm too ambitious trying to run this model in the first place, but such a feature would surely come in handy when fine tuning and tinkering.
As for the builds of llama.cpp, it's been a while since I've had issues with them. The last few times I got the correct CUDA build instead of the CPU-only one.
danielhanchen commentedon Oct 11, 2026
Fixed! Sorry on the delay. When a llama.cpp folder had a CPU-only
buildnext to a CUDAbuild-cuda, Studio always took the first one it found, so inference ran on the CPU while training used the GPU. Since #11005 Studio checks which builds actually ship a GPU backend and prefers the one your GPU can run, and since #8812 it warns in the UI when a model loads with no layers (or only some) on the GPU. If you setLLAMA_SERVER_PATHyourself, that exact binary is still used as-is, so point it at the CUDA build or remove it.@Pavlogal what you saw is a different thing: a 12B with the vision projector and MTP draft does not fit in 8 GB, so llama.cpp's own fitter keeps only part of the model on the GPU. Since #6414 you can override that in the model settings under Advanced > GPU Memory > Manual, then set GPU Layers (the same as
--gpu-layers). On Windows a value above what fits can still run because the NVIDIA driver spills to system RAM.@mr-pepe69 if Docker still runs inference on the CPU after updating, please open a new issue with the
Starting llama-serverline and the llama-server startup log.To update: Unsloth Desktop will have an update banner. For Studio, use
unsloth studio update. For Docker, usedocker exec <container> unsloth-studio-update. Reopen if it still happens.mithulaartigala commentedon Oct 11, 2026
NICEE!!! TYSM!!!
Unsloth Studio the goat!!