[GH-ISSUE #10575] Setting priority of Ollama under Windows #84642

Open
opened 2026-05-09 21:15:28 -05:00 by GiteaMirror · 13 comments
Owner

Originally created by @pereswa on GitHub (May 5, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/10575

Originally assigned to: @dhiltgen on GitHub.

I noticed that Ollama runs the instance running an active model with "above normal" priority (I hope that's the correct translation for German "Höher als normal") in Windows 10 & 11.
Unfortunatelly this instance is then completely blocking the whole PC when processing a request - it becomes completely unresponsive until Ollama is finished (or cancelled via Ctrl+C).

Therefore I tried to start the server with "below normal" priority - but that doesn't work:
Every instance loading a model is started with "above normal" priority.
Today I always check the priority before sending a request to make sure it doesn't block my PC.

I didn't find a solution for this - maybe there is a environment variable for this issue?
I didn't find any documentation about these - two are mentioned in FAQ "Setting environment variables on Windows".

So, I wish there was either an environment variable to set instance priority or the priority was inherited from the server.

While looking for a solution I also noticed when limiting the instance running a model to certain CPU cores (simulating a "below normal" priority ;) this instance becomes very very very slow. E.g. if limited to 4 of 6 cores, it runs with like 5% of the performance as before when it had all 6 cores.

Originally created by @pereswa on GitHub (May 5, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/10575 Originally assigned to: @dhiltgen on GitHub. I noticed that Ollama runs the instance running an active model with "above normal" priority (I hope that's the correct translation for German "Höher als normal") in Windows 10 & 11. Unfortunatelly this instance is then completely blocking the whole PC when processing a request - it becomes completely unresponsive until Ollama is finished (or cancelled via Ctrl+C). Therefore I tried to start the server with "below normal" priority - but that doesn't work: Every instance loading a model is started with "above normal" priority. Today I always check the priority before sending a request to make sure it doesn't block my PC. I didn't find a solution for this - maybe there is a environment variable for this issue? I didn't find any documentation about these - two are mentioned in FAQ "Setting environment variables on Windows". So, I wish there was either an environment variable to set instance priority or the priority was inherited from the server. While looking for a solution I also noticed when limiting the instance running a model to certain CPU cores (simulating a "below normal" priority ;) this instance becomes very very very slow. E.g. if limited to 4 of 6 cores, it runs with like 5% of the performance as before when it had all 6 cores.
GiteaMirror added the windowsfeature request labels 2026-05-09 21:15:29 -05:00
Author
Owner

@mrpras commented on GitHub (May 9, 2025):

Try Process Tamer - was the lightest solution for me in terms of something I want to leave running constantly and it's simple, just works.

www donationcoder com/software/mouser/popular-apps/process-tamer

<!-- gh-comment-id:2865576809 --> @mrpras commented on GitHub (May 9, 2025): Try Process Tamer - was the lightest solution for me in terms of something I want to leave running constantly and it's simple, just works. www donationcoder com/software/mouser/popular-apps/process-tamer
Author
Owner

@pereswa commented on GitHub (May 14, 2025):

This tool doesn't seem to work on Windows 10 or 11.

<!-- gh-comment-id:2879393189 --> @pereswa commented on GitHub (May 14, 2025): This tool doesn't seem to work on Windows 10 or 11.
Author
Owner

@pereswa commented on GitHub (May 26, 2025):

I found the reason for this behaviour:
https://github.com/ollama/ollama/blob/main/llm/llm_windows.go#L22

The explanation "Setting Above Normal priority class ensures when running as a "background service" with "programs" given best priority, we aren't starved of cpu cycles" seems to be valid for current and recent but not for older hardware.

On a i3-1115G4 Ollama runs fine with above normal priority.
But on my i5-8500t it grabs all ressources and renders the PC unresponsive while processing requests.
Both running Windows 10.

I just tried "How to Permanently Set Priority Processes Using Registry Editor":
https://answers.microsoft.com/en-us/windows/forum/all/how-to-permanently-set-priority-processes-using/df82bd40-ce52-4b84-af34-4d93da17d079
And it works, kind of:

I started the server with: start "Ollama" /low "%LOCALAPPDATA%\Programs\Ollama\ollama app.exe"
-> it runs with Low (Niedrig) OK

Subsequently started programs are started with th priority set via registry, as described above.
-> these run with Below normal (Niedriger als Normal) OK

But the also subsequently started model instance overrides the registry setting (nor inherits priority from server) and sets its own priority.
-> the model runs with Above normal (Höher als normal) Not OK

Image

So, the current implementation overrides all local settings and preferences.

Maybe this should be seen as a support for older/weaker hardware fix.

<!-- gh-comment-id:2909982724 --> @pereswa commented on GitHub (May 26, 2025): I found the reason for this behaviour: https://github.com/ollama/ollama/blob/main/llm/llm_windows.go#L22 The explanation _"Setting Above Normal priority class ensures when running as a "background service" with "programs" given best priority, we aren't starved of cpu cycles"_ seems to be valid for current and recent but not for older hardware. On a i3-1115G4 Ollama runs fine with above normal priority. But on my i5-8500t it grabs all ressources and renders the PC unresponsive while processing requests. Both running Windows 10. I just tried "How to Permanently Set Priority Processes Using Registry Editor": https://answers.microsoft.com/en-us/windows/forum/all/how-to-permanently-set-priority-processes-using/df82bd40-ce52-4b84-af34-4d93da17d079 And it works, kind of: I started the server with: start "Ollama" /low "%LOCALAPPDATA%\Programs\Ollama\ollama app.exe" -> it runs with Low (Niedrig) _OK_ Subsequently started programs are started with th priority set via registry, as described above. -> these run with Below normal (Niedriger als Normal) _OK_ But the also subsequently started model instance overrides the registry setting (nor inherits priority from server) and sets its own priority. -> the model runs with Above normal (Höher als normal) **_Not OK_** ![Image](https://github.com/user-attachments/assets/63430ef8-6e84-43cf-8c6a-7dfa03872599) So, the current implementation overrides all local settings and preferences. Maybe this should be seen as a support for older/weaker hardware fix.
Author
Owner

@mrpras commented on GitHub (May 27, 2025):

This tool doesn't seem to work on Windows 10 or 11.

I'm using it on Windows 10 right now to "tame" Ollama and some other tasks. You can also set things to higher priority.

Otherwise you could try "system informer" which is much deeper but also does have the option to save priorities per process.

<!-- gh-comment-id:2912521805 --> @mrpras commented on GitHub (May 27, 2025): > This tool doesn't seem to work on Windows 10 or 11. I'm using it on Windows 10 right now to "tame" Ollama and some other tasks. You can also set things to higher priority. Otherwise you could try "system informer" which is much deeper but also does have the option to save priorities per process.
Author
Owner

@pereswa commented on GitHub (May 27, 2025):

That's strange. I tried it on both versions and it did nothing.
The build in "task list" showed the running tasks but all with 0% CPU usage.

The developer's programs look all very Windows 7-ish or older ;)
But it's/was nice to share the stuff he made probably for his own usage.

I now have a batch file (WMIC process where name="ollama.exe" CALL setpriority "below normal") linked to my task bar - whenever Ollama gets out of control, relief is just one click (and 2-3 seconds) away.
As Ollama is the only program with such strange behaviour, I can live with this fix.
Nonetheless I think this "above normal" priority setting for a non-system program should be fixed - I hope someone has a heart for older/weaker hardware.

@mrpras, thank you for trying to help me :)

<!-- gh-comment-id:2913817167 --> @pereswa commented on GitHub (May 27, 2025): That's strange. I tried it on both versions and it did nothing. The build in "task list" showed the running tasks but all with 0% CPU usage. The developer's programs look all very Windows 7-ish or older ;) But it's/was nice to share the stuff he made probably for his own usage. I now have a batch file (WMIC process where name="ollama.exe" CALL setpriority "below normal") linked to my task bar - whenever Ollama gets out of control, relief is just one click (and 2-3 seconds) away. As Ollama is the only program with such strange behaviour, I can live with this fix. Nonetheless I think this "above normal" priority setting for a non-system program should be fixed - I hope someone has a heart for older/weaker hardware. @mrpras, thank you for trying to help me :)
Author
Owner

@mrpras commented on GitHub (May 28, 2025):

@mrpras, thank you for trying to help me :)

Happy to try :)

A couple of final thoughts though - possibly windows defender is blocking the execution of the process tamer (I always strip out defender because it's rubbish). It might also be a lack of the correct VC Redistributables (you can install the whole lot via a pack such as this - https://www.techpowerup.com/download/visual-c-redistributable-runtime-package-all-in-one/

Also you might try to set the priority in the registry
https://answers.microsoft.com/en-us/windows/forum/all/how-to-permanently-set-priority-processes-using/2f9ec439-5333-4625-9577-69d322cfbc5e

<!-- gh-comment-id:2915351126 --> @mrpras commented on GitHub (May 28, 2025): > [@mrpras](https://github.com/mrpras), thank you for trying to help me :) Happy to try :) A couple of final thoughts though - possibly windows defender is blocking the execution of the process tamer (I always strip out defender because it's rubbish). It might also be a lack of the correct VC Redistributables (you can install the whole lot via a pack such as this - https://www.techpowerup.com/download/visual-c-redistributable-runtime-package-all-in-one/ Also you might try to set the priority in the registry https://answers.microsoft.com/en-us/windows/forum/all/how-to-permanently-set-priority-processes-using/2f9ec439-5333-4625-9577-69d322cfbc5e
Author
Owner

@LanceJZ commented on GitHub (Jun 11, 2025):

Even on not old/weak hardware it makes it so if you try to do anything else on the system it causes pain. Please fix so you can either adjust using a environment variable or something. Having to do a work around is a pain.

<!-- gh-comment-id:2964324821 --> @LanceJZ commented on GitHub (Jun 11, 2025): Even on not old/weak hardware it makes it so if you try to do anything else on the system it causes pain. Please fix so you can either adjust using a environment variable or something. Having to do a work around is a pain.
Author
Owner

@LanceJZ commented on GitHub (Jun 11, 2025):

That's strange. I tried it on both versions and it did nothing. The build in "task list" showed the running tasks but all with 0% CPU usage.

The developer's programs look all very Windows 7-ish or older ;) But it's/was nice to share the stuff he made probably for his own usage.

I now have a batch file (WMIC process where name="ollama.exe" CALL setpriority "below normal") linked to my task bar - whenever Ollama gets out of control, relief is just one click (and 2-3 seconds) away. As Ollama is the only program with such strange behaviour, I can live with this fix. Nonetheless I think this "above normal" priority setting for a non-system program should be fixed - I hope someone has a heart for older/weaker hardware.

@mrpras, thank you for trying to help me :)

I tried WMIC process where name="ollama.exe" CALL setpriority "below normal" but I got ERROR:
Description = Invalid query

Oh, so that was in Powershell, doh. Is there a way to run this as a Powershell script?

<!-- gh-comment-id:2964429612 --> @LanceJZ commented on GitHub (Jun 11, 2025): > That's strange. I tried it on both versions and it did nothing. The build in "task list" showed the running tasks but all with 0% CPU usage. > > The developer's programs look all very Windows 7-ish or older ;) But it's/was nice to share the stuff he made probably for his own usage. > > I now have a batch file (WMIC process where name="ollama.exe" CALL setpriority "below normal") linked to my task bar - whenever Ollama gets out of control, relief is just one click (and 2-3 seconds) away. As Ollama is the only program with such strange behaviour, I can live with this fix. Nonetheless I think this "above normal" priority setting for a non-system program should be fixed - I hope someone has a heart for older/weaker hardware. > > [@mrpras](https://github.com/mrpras), thank you for trying to help me :) I tried WMIC process where name="ollama.exe" CALL setpriority "below normal" but I got ERROR: Description = Invalid query Oh, so that was in Powershell, doh. Is there a way to run this as a Powershell script?
Author
Owner

@pereswa commented on GitHub (Jun 12, 2025):

Hi, @LanceJZ. I simplified the solution in the meantime.

Just create a Shortcut on your desktop and put this in the target field:

C:\Windows\System32\cmd.exe /c WMIC process where name="ollama.exe" CALL setpriority "below normal"

For "Run:" choose "Minimized".
(I use the blue downward arrow icon in shell32.dll as icon ;)

Then drag it to your taskbar.

When running Ollama and just before sending a request, just click on it.

<!-- gh-comment-id:2967235711 --> @pereswa commented on GitHub (Jun 12, 2025): Hi, @LanceJZ. I simplified the solution in the meantime. Just create a Shortcut on your desktop and put this in the target field: `C:\Windows\System32\cmd.exe /c WMIC process where name="ollama.exe" CALL setpriority "below normal"` For "Run:" choose "Minimized". (I use the blue downward arrow icon in shell32.dll as icon ;) Then drag it to your taskbar. When running Ollama and just before sending a request, just click on it.
Author
Owner

@dhiltgen commented on GitHub (Jul 5, 2025):

I'm not quite sure what the right answer is, but we added this bump in priority to address what numerous users were seeing where the ollama serve running at "normal" priority was getting starved of CPU and inference speeds were horribly slow. "Above normal" fixed that problem.

<!-- gh-comment-id:3040337888 --> @dhiltgen commented on GitHub (Jul 5, 2025): I'm not quite sure what the right answer is, but we added this bump in priority to address what numerous users were seeing where the `ollama serve` running at "normal" priority was getting starved of CPU and inference speeds were horribly slow. "Above normal" fixed that problem. - https://github.com/ollama/ollama/blob/main/llm/llm_windows.go#L9 - https://github.com/ollama/ollama/pull/6905
Author
Owner

@pereswa commented on GitHub (Jul 20, 2025):

Hi @dhiltgen ,
thank you for adding the reference to the initial change.

I understand you fixed the issue many users had with setting the priority to "above normal".
But it causes other users to have issues running Ollama - probably on weaker machines (like a i5-8500t).

Like @Lukasr29, I don't need an immedieate answer on my PC, but I'm fine letting Ollama produce an answer in the background.
I even prefer to run Ollama at "below normal" than "normal" - thus not slowing my foreground tasks.
Unfortunately the always performed set to "above normal" when a model is loaded or reloaded blocks the PC completely.

>ollama run -h
Run a model

Usage:
  ollama run MODEL [PROMPT] [flags]

Flags:
      --format string      Response format (e.g. json)
  -h, --help               help for run
      --insecure           Use an insecure registry
      --keepalive string   Duration to keep a model loaded (e.g. 5m)
      --nowordwrap         Don't wrap words to the next line automatically
      --verbose            Show timings for response

Environment Variables:
      OLLAMA_HOST                IP Address for the ollama server (default 127.0.0.1:11434)
      OLLAMA_NOHISTORY           Do not preserve readline history

As the "above normal" priority is set when a model is (re)loaded, it probably makes sense to make the desired priority setting part of the run command. That would add more flexibility than setting an environment variable.
It probably could be simplified to the desired use case: --background (for "below normal") or --foreground (for "above normal").
Or "above normal" as default with an optional flag like --belownormal for weaker PCs which stay responsive with this priority.

Unfortunately I'm not familiar with the language Ollama is coded in, nor the environment.
So, I rely on someone who is capable and willing to help me (and the other users with weaker machines).

<!-- gh-comment-id:3094461102 --> @pereswa commented on GitHub (Jul 20, 2025): Hi @dhiltgen , thank you for adding the reference to the initial change. I understand you fixed the issue many users had with setting the priority to "above normal". But it causes other users to have issues running Ollama - probably on weaker machines (like a i5-8500t). Like @Lukasr29, I don't need an immedieate answer on my PC, but I'm fine letting Ollama produce an answer in the background. I even prefer to run Ollama at "below normal" than "normal" - thus not slowing my foreground tasks. Unfortunately the always performed set to "above normal" when a model is loaded or reloaded blocks the PC completely. ``` >ollama run -h Run a model Usage: ollama run MODEL [PROMPT] [flags] Flags: --format string Response format (e.g. json) -h, --help help for run --insecure Use an insecure registry --keepalive string Duration to keep a model loaded (e.g. 5m) --nowordwrap Don't wrap words to the next line automatically --verbose Show timings for response Environment Variables: OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434) OLLAMA_NOHISTORY Do not preserve readline history ``` As the "above normal" priority is set when a model is (re)loaded, it probably makes sense to make the desired priority setting part of the run command. That would add more flexibility than setting an environment variable. It probably could be simplified to the desired use case: --background (for "below normal") or --foreground (for "above normal"). Or "above normal" as default with an optional flag like --belownormal for weaker PCs which stay responsive with this priority. Unfortunately I'm not familiar with the language Ollama is coded in, nor the environment. So, I rely on someone who is capable and willing to help me (and the other users with weaker machines).
Author
Owner

@pereswa commented on GitHub (Aug 22, 2025):

Update:
I came to the conclusion that this issue is probably linked to the cores-threads relation.
I noticed that on PCs with hyper-threading CPUs there is no issue - Ollama runs with above-normal priority and the system is responsive.
But on PCs with CPUs w/o hyper-threading (cores=threads) - especially weaker ones - Ollama even can even crash after blocking the system for several minutes. I have lost some nice discussions due to this aleady :(

On a very weak G5400t (2 cores/4 threads) w/o GPU but 16 GB RAM Ollama works (but too slow) and the system is still responsive and usable. Likewise Ollama works fine on a i7-8700t (w/o GPU) or Ryzen 7 7435 HS (with RTX 4060) and the system is responsive.

But on a i5-7500 (4/4) or i5-8500t (6/6) w/o GPU but 32 GB RAM Ollama grabs all CPU power and blocks the user out.

I noticed related discussions about why Ollama isn't utilizing all threads but only real cores:
we allocate 1 thread per real core, and don't create 2 threads accidentally based on hyperthreads, which yields thrashing and much poorer performance

So, Ollama does not utilize the whole CPU on systems with a CPU with hyper-threading (because hyper-threading makes unused CPU resources available). But Ollama utilizes the whole CPU on systems with CPU w/o hyper-threading b/c no ressources left.
Should this be considered a bug, as it can crash Ollama and can make the PC unresponsive?

I noticed - beside the work-around described above - I can prevent the issue by setting num_thread to the number of CPU cores - 1.
(btw. num_thread is not described for the "/set parameter" command, but works)
Maybe running with one thread less than cores available on CPUs w/o hyper-threading could be a general solutions?

<!-- gh-comment-id:3214267711 --> @pereswa commented on GitHub (Aug 22, 2025): Update: I came to the conclusion that this issue is probably linked to the cores-threads relation. I noticed that on PCs with hyper-threading CPUs there is no issue - Ollama runs with above-normal priority and the system is responsive. But on PCs with CPUs w/o hyper-threading (cores=threads) - especially weaker ones - Ollama even can even crash after blocking the system for several minutes. I have lost some nice discussions due to this aleady :( On a very weak G5400t (2 cores/4 threads) w/o GPU but 16 GB RAM Ollama works (but too slow) and the system is still responsive and usable. Likewise Ollama works fine on a i7-8700t (w/o GPU) or Ryzen 7 7435 HS (with RTX 4060) and the system is responsive. But on a i5-7500 (4/4) or i5-8500t (6/6) w/o GPU but 32 GB RAM Ollama grabs all CPU power and blocks the user out. I noticed related discussions about why Ollama isn't utilizing all threads but only real cores: [we allocate 1 thread per real core, and don't create 2 threads accidentally based on hyperthreads, which yields thrashing and much poorer performance](https://github.com/ollama/ollama/issues/2929#issuecomment-1981312519) So, Ollama does not utilize the whole CPU on systems with a CPU with hyper-threading (because hyper-threading makes _unused_ CPU resources available). But Ollama utilizes the whole CPU on systems with CPU w/o hyper-threading b/c no ressources left. Should this be considered a bug, as it can crash Ollama and can make the PC unresponsive? I noticed - beside the work-around described above - I can prevent the issue by setting num_thread to the number of CPU cores - 1. (btw. num_thread is not described for the "/set parameter" command, but works) Maybe running with one thread less than cores available on CPUs w/o hyper-threading could be a general solutions?
Author
Owner

@kymograph commented on GitHub (Aug 30, 2025):

There is a pr waiting quite a while already for review to configure the process priority with an environment variable https://github.com/ollama/ollama/pull/8751

Would love to see this being merged.

<!-- gh-comment-id:3239181442 --> @kymograph commented on GitHub (Aug 30, 2025): There is a pr waiting quite a while already for review to configure the process priority with an environment variable https://github.com/ollama/ollama/pull/8751 Would love to see this being merged.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#84642