[PR #11463] Add OLLAMA_RUNNER_THREADS environment variable to allow for control of the number of runner cpu threads created #13549

Open
opened 2026-04-13 00:29:58 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/ollama/ollama/pull/11463

State: open
Merged: No


Was running on my dual xeon server and was only getting half the worker thread as I expected because of the logic around that. Current behaviour makes sense as an automatic default, but this should be configurable by anyone deploying on their machine so they can tweak as they see fit.

Environment Variable Setup:

  • envconfig/config.go: Added RunnerThreads as a new environment variable to configure thread count. Updated the AsMap method to include documentation for the new variable. [1] [2]

Application Logic:

  • cmd/cmd.go: Integrated OLLAMA_RUNNER_THREADS into the CLI environment variables list for documentation purposes.
  • runner/ollamarunner/runner.go: Updated the Execute function to check for OLLAMA_RUNNER_THREADS and override the default thread count if the environment variable is set.

Testing:

  • runner/ollamarunner/threads_test.go: Added unit and integration tests to validate the behavior of OLLAMA_RUNNER_THREADS, ensuring proper handling of valid, invalid, and unset values, as well as integration with runtime defaults.
**Original Pull Request:** https://github.com/ollama/ollama/pull/11463 **State:** open **Merged:** No --- Was running on my dual xeon server and was only getting half the worker thread as I expected because of the logic around that. Current behaviour makes sense as an automatic default, but this should be configurable by anyone deploying on their machine so they can tweak as they see fit. ### Environment Variable Setup: * [`envconfig/config.go`](diffhunk://#diff-f2766e983a91949170e97b80faaf822c3e362af58cc65b9c38a2a09d84a6bd1bR227-R228): Added `RunnerThreads` as a new environment variable to configure thread count. Updated the `AsMap` method to include documentation for the new variable. [[1]](diffhunk://#diff-f2766e983a91949170e97b80faaf822c3e362af58cc65b9c38a2a09d84a6bd1bR227-R228) [[2]](diffhunk://#diff-f2766e983a91949170e97b80faaf822c3e362af58cc65b9c38a2a09d84a6bd1bR274) ### Application Logic: * [`cmd/cmd.go`](diffhunk://#diff-8e494a434a8037b6c0b888e25b2baae7618fe65e792d4a155dadd096e9350667R1576): Integrated `OLLAMA_RUNNER_THREADS` into the CLI environment variables list for documentation purposes. * [`runner/ollamarunner/runner.go`](diffhunk://#diff-8138918098aff3e64b3e34dc9904bcb4f55c1798c01c948795ed69ea00c99fffR941-R945): Updated the `Execute` function to check for `OLLAMA_RUNNER_THREADS` and override the default thread count if the environment variable is set. ### Testing: * [`runner/ollamarunner/threads_test.go`](diffhunk://#diff-8d5614356e0e54231b7ec5ed7bb2ebf782dfeb693aa0810866fafb56ee99b839R1-R124): Added unit and integration tests to validate the behavior of `OLLAMA_RUNNER_THREADS`, ensuring proper handling of valid, invalid, and unset values, as well as integration with runtime defaults.
GiteaMirror added the pull-request label 2026-04-13 00:29:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#13549