[PR #15763] Prevent system sleep during inference (fixes #4072) #61995

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

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15763
Author: @ClawdiaHedgehog
Created: 4/23/2026
Status: 🔄 Open

Base: mainHead: feature/prevent-sleep-during-inference


📝 Commits (1)

  • 7218f92 Prevent system sleep during inference (fixes #4072)

📊 Changes

2 files changed (+56 additions, -0 deletions)

View changed files

server/power_saver.go (+52 -0)
📝 server/routes.go (+4 -0)

📄 Description

Summary

This PR implements power management to prevent the system from sleeping during inference operations.

Changes

  • Added server/power_saver.go with AcquirePowerLock() and ReleasePowerLock() functions
  • Uses caffeinate on macOS to prevent idle sleep
  • Uses systemd-inhibit on Linux to prevent idle sleep
  • Integrated power locking into GenerateHandler and ChatHandler

Motivation

Fixes issue #4072: Ollama should prevent sleep when working on heavy inference tasks.

Testing

The implementation uses reference counting to handle concurrent inference requests - power is saved until all inference requests complete.

Fixes #4072

🔄 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/15763 **Author:** [@ClawdiaHedgehog](https://github.com/ClawdiaHedgehog) **Created:** 4/23/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feature/prevent-sleep-during-inference` --- ### 📝 Commits (1) - [`7218f92`](https://github.com/ollama/ollama/commit/7218f923049a774bdb1a65d8d86a844bd42ed232) Prevent system sleep during inference (fixes #4072) ### 📊 Changes **2 files changed** (+56 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `server/power_saver.go` (+52 -0) 📝 `server/routes.go` (+4 -0) </details> ### 📄 Description ## Summary This PR implements power management to prevent the system from sleeping during inference operations. ## Changes - Added `server/power_saver.go` with `AcquirePowerLock()` and `ReleasePowerLock()` functions - Uses `caffeinate` on macOS to prevent idle sleep - Uses `systemd-inhibit` on Linux to prevent idle sleep - Integrated power locking into `GenerateHandler` and `ChatHandler` ## Motivation Fixes issue #4072: Ollama should prevent sleep when working on heavy inference tasks. ## Testing The implementation uses reference counting to handle concurrent inference requests - power is saved until all inference requests complete. ``` Fixes #4072 ``` --- <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 2026-04-29 16:57:13 -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#61995