[GH-ISSUE #15704] False "insufficient memory" error in LXC: Ollama appears to use MemFree instead of MemAvailable when loading models #72074

Open
opened 2026-05-05 03:25:08 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @avgex on GitHub (Apr 19, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/15704

What is the issue?

Ollama refuses to load a model in an LXC container even though the container has enough reclaimable memory available.

Environment:

  • Proxmox LXC container
  • Debian guest
  • Container memory: 32 GiB
  • Container swap: 512 MiB
  • CPU inference only

Observed behavior:
When I try to load gemma4:26b, Ollama returns:

model requires more system memory (18.3 GiB) than is available (12.6 GiB)

However, inside the container:

  • MemFree is about 12 GiB
  • MemAvailable is about 31.9 GiB
  • almost no RAM is used by processes
  • about 21 GiB is file cache, mostly inactive_file, so it should be reclaimable by Linux

This suggests Ollama is using something close to MemFree + SwapFree for its pre-load memory check, while ignoring reclaimable page cache / MemAvailable.

Why I believe this is incorrect:

  • free -h shows:
    • free: ~12 GiB
    • available: ~31 GiB
  • /sys/fs/cgroup/memory.stat shows:
    • anon: ~35 MiB
    • file: ~21.2 GiB
    • inactive_file: ~21.1 GiB
  • ps aux --sort=-%mem shows no large memory-consuming processes

So the memory is not actually occupied by applications. It is mostly page cache.

Expected behavior:
Ollama should either:

  1. use MemAvailable instead of only MemFree, or
  2. account for reclaimable file cache, or
  3. provide an override / more aggressive loading option

Actual behavior:
Ollama refuses to load the model even though Linux should be able to reclaim enough cache to make room.

Notes:

  • Restarting only the ollama service does not help
  • Restarting the whole container may temporarily help because cache is cleared
  • This looks especially relevant for containerized environments such as LXC

Relevant log output

Apr 19 17:31:46 ollama ollama[199195]: time=2026-04-19T17:31:46.564+02:00 level=INFO source=types.go:60 msg="inference compute" id=cpu library=cpu compute="" name=cpu description=cpu libdirs=ollama driver="" pci_id="" type="" total="32.0 GiB" available="12.1 GiB"
Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.309+02:00 level=INFO source=sched.go:484 msg="system memory" total="32.0 GiB" free="12.1 GiB" free_swap="506.2 MiB"
Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=WARN source=server.go:1058 msg="model request too large for system" requested="18.3 GiB" available="12.6 GiB" total="32.0 GiB" free="12.1 GiB" swap="506.2 MiB"
Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=INFO source=device.go:245 msg="model weights" device=CPU size="17.3 GiB"
Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=INFO source=device.go:256 msg="kv cache" device=CPU size="880.0 MiB"
Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=INFO source=device.go:267 msg="compute graph" device=CPU size="133.7 MiB"
Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=INFO source=device.go:272 msg="total memory" size="18.3 GiB"
Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=INFO source=sched.go:511 msg="Load failed" model=/usr/share/ollama/.ollama/models/blobs/sha256-7121486771cbfe218851513210c40b35dbdee93ab1ef43fe36283c883980f0df error="model requires more system memory (18.3 GiB) than is available (12.6 GiB)"
Apr 19 17:32:08 ollama ollama[199195]: [GIN] 2026/04/19 - 17:32:08 | 500 | 595.882098ms | 192.168.1.239 | POST "/api/chat"

Inside the container:

free -h
---------------
               total        used        free      shared  buff/cache   available
Mem:            32Gi        44Mi        12Gi        72Ki        19Gi        31Gi
Swap:          512Mi       5.8Mi       506Mi

/proc/meminfo
---------------
MemTotal:       33554432 kB
MemFree:        12726260 kB
MemAvailable:   33508662 kB
SwapTotal:        524288 kB
SwapFree:         518352 kB

/sys/fs/cgroup/memory.stat
---------------
anon 36884480
file 21266915328
inactive_file 21189849088
active_file 77045760

OS

Linux

GPU

No response

CPU

Intel

Ollama version

0.20.5

Originally created by @avgex on GitHub (Apr 19, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/15704 ### What is the issue? Ollama refuses to load a model in an LXC container even though the container has enough reclaimable memory available. Environment: - Proxmox LXC container - Debian guest - Container memory: 32 GiB - Container swap: 512 MiB - CPU inference only Observed behavior: When I try to load `gemma4:26b`, Ollama returns: `model requires more system memory (18.3 GiB) than is available (12.6 GiB)` However, inside the container: - `MemFree` is about 12 GiB - `MemAvailable` is about 31.9 GiB - almost no RAM is used by processes - about 21 GiB is file cache, mostly `inactive_file`, so it should be reclaimable by Linux This suggests Ollama is using something close to `MemFree + SwapFree` for its pre-load memory check, while ignoring reclaimable page cache / `MemAvailable`. Why I believe this is incorrect: - `free -h` shows: - free: ~12 GiB - available: ~31 GiB - `/sys/fs/cgroup/memory.stat` shows: - anon: ~35 MiB - file: ~21.2 GiB - inactive_file: ~21.1 GiB - `ps aux --sort=-%mem` shows no large memory-consuming processes So the memory is not actually occupied by applications. It is mostly page cache. Expected behavior: Ollama should either: 1. use `MemAvailable` instead of only `MemFree`, or 2. account for reclaimable file cache, or 3. provide an override / more aggressive loading option Actual behavior: Ollama refuses to load the model even though Linux should be able to reclaim enough cache to make room. Notes: - Restarting only the `ollama` service does not help - Restarting the whole container may temporarily help because cache is cleared - This looks especially relevant for containerized environments such as LXC ### Relevant log output ```shell Apr 19 17:31:46 ollama ollama[199195]: time=2026-04-19T17:31:46.564+02:00 level=INFO source=types.go:60 msg="inference compute" id=cpu library=cpu compute="" name=cpu description=cpu libdirs=ollama driver="" pci_id="" type="" total="32.0 GiB" available="12.1 GiB" Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.309+02:00 level=INFO source=sched.go:484 msg="system memory" total="32.0 GiB" free="12.1 GiB" free_swap="506.2 MiB" Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=WARN source=server.go:1058 msg="model request too large for system" requested="18.3 GiB" available="12.6 GiB" total="32.0 GiB" free="12.1 GiB" swap="506.2 MiB" Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=INFO source=device.go:245 msg="model weights" device=CPU size="17.3 GiB" Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=INFO source=device.go:256 msg="kv cache" device=CPU size="880.0 MiB" Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=INFO source=device.go:267 msg="compute graph" device=CPU size="133.7 MiB" Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=INFO source=device.go:272 msg="total memory" size="18.3 GiB" Apr 19 17:32:08 ollama ollama[199195]: time=2026-04-19T17:32:08.568+02:00 level=INFO source=sched.go:511 msg="Load failed" model=/usr/share/ollama/.ollama/models/blobs/sha256-7121486771cbfe218851513210c40b35dbdee93ab1ef43fe36283c883980f0df error="model requires more system memory (18.3 GiB) than is available (12.6 GiB)" Apr 19 17:32:08 ollama ollama[199195]: [GIN] 2026/04/19 - 17:32:08 | 500 | 595.882098ms | 192.168.1.239 | POST "/api/chat" Inside the container: free -h --------------- total used free shared buff/cache available Mem: 32Gi 44Mi 12Gi 72Ki 19Gi 31Gi Swap: 512Mi 5.8Mi 506Mi /proc/meminfo --------------- MemTotal: 33554432 kB MemFree: 12726260 kB MemAvailable: 33508662 kB SwapTotal: 524288 kB SwapFree: 518352 kB /sys/fs/cgroup/memory.stat --------------- anon 36884480 file 21266915328 inactive_file 21189849088 active_file 77045760 ``` ### OS Linux ### GPU _No response_ ### CPU Intel ### Ollama version 0.20.5
GiteaMirror added the bug label 2026-05-05 03:25:08 -05:00
Author
Owner

@two56bytes commented on GitHub (Apr 21, 2026):

+1

<!-- gh-comment-id:4288248898 --> @two56bytes commented on GitHub (Apr 21, 2026): +1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#72074