[PR #12396] Fix the inappropriate thread count for Ollama in the Docker scenario #12547

Open
opened 2025-11-12 16:38:29 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/12396
Author: @dingdongxiangvolc
Created: 9/24/2025
Status: 🔄 Open

Base: mainHead: main


📝 Commits (1)

  • d9a3417 discover: Adjust CPU info obtained by Ollama under cgroup restrictions

📊 Changes

1 file changed (+48 additions, -0 deletions)

View changed files

📝 discover/gpu_linux.go (+48 -0)

📄 Description

When running Ollama inside Docker on machines with many CPUs, limiting the container’s CPU caused the number of threads Ollama spawns to mismatch the CPUs the container is allowed to use, significantly reducing inference performance. This commit slightly modifies Ollama to detect the number of CPUs the container is restricted to for better thread count alignment.

Note: Currently, this only supports CPU limits set via --cpuset-cpus; other limiting methods are not yet supported.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/12396 **Author:** [@dingdongxiangvolc](https://github.com/dingdongxiangvolc) **Created:** 9/24/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`d9a3417`](https://github.com/ollama/ollama/commit/d9a341794184440c6173e494603d5bd9fc662bb9) discover: Adjust CPU info obtained by Ollama under cgroup restrictions ### 📊 Changes **1 file changed** (+48 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `discover/gpu_linux.go` (+48 -0) </details> ### 📄 Description When running Ollama inside Docker on machines with many CPUs, limiting the container’s CPU caused the number of threads Ollama spawns to mismatch the CPUs the container is allowed to use, significantly reducing inference performance. This commit slightly modifies Ollama to detect the number of CPUs the container is restricted to for better thread count alignment. Note: Currently, this only supports CPU limits set via --cpuset-cpus; other limiting methods are not yet supported. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-12 16:38:29 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama-ollama#12547