Skip to content

[Feature] Add sleep-idle-seconds #2239

Open

Description

@cumal

Feature Summary

As llama.cpp, add sleep-idle-seconds flag to free vram when not using

Detailed Description

In my case, it would be great to have llama.cpp and stable.diffusion.cpp in the same machine at the same time, but sometimes, when not using stable or llama, free the vram for the other one or other processes.

Alternatives you considered

No response

Additional context

https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md

Activity

  1. added
    enhancement
    on Oct 28, 2026
  2. cs8425 commented on Oct 31, 2026

    @cs8425

    Currently I'm using flag --offload-to-cpu to do this: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/performance.md#offload-weights-to-the-cpu-to-save-vram-without-reducing-generation-speed
    It load weights into VRAM only when needed and offload immediately when generate finish.
    This may be a workaround right now.

  3. ampersandru commented on Nov 5, 2026

    @ampersandru

    I've implemented this in my fork: feat/server-idle-sleep.

    It adds --sleep-idle-seconds N (also available as --ttl N) to unload the model context after a configurable idle period and automatically reload it on the next generation request. Active requests and queued/running jobs prevent unloading, and status/progress polling doesn't reset the idle timer. It also preserves models loaded through command-line arguments, so no recipe is required.

    Initial testing with Docker, CUDA, an RTX 5060 Ti, and Open WebUI is working well. I'll do more testing before opening a PR.

    @cumal I see you opened and closed a PR due to web ui not picking up models after it unloaded. I can confirm I can still see and load models after one is unloaded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions