[GH-ISSUE #9168] Ollama llm server error because of the competition for CPU and GPU memory resources #31728

Closed
opened 2026-04-22 12:26:53 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @saeya211 on GitHub (Feb 17, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9168

ollama info:

version:
config: OLLAMA_MAX_LOADED_MODELS = 3

for example:
ollama ps shows three models: model-A, model-B, model-C.
These models are used at the same time, like user1 is chating with model-A, user2 is chating with model-B, user3 is chating with model-C
User4 wanna to chat with model-D now, then the issue will happen.

ERROR log:
2025-02-16T06:10:14.783407+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.783Z level=INFO source=server.go:376 msg="starting llama server" cmd="/usr/local/lib/ollama/runners/cuda_v12_avx/ollama_llama_server runner --model /data/olla
ma/models/blobs/sha256-a677b4a4b70c45e702b1d600f7905e367733c53898b8be60e3f29272cf334574 --ctx-size 8192 --batch-size 512 --n-gpu-layers 81 --threads 6 --parallel 4 --port 36267"
2025-02-16T06:10:14.783779+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.783Z level=INFO source=sched.go:449 msg="loaded runners" count=2
2025-02-16T06:10:14.783831+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.783Z level=INFO source=server.go:555 msg="waiting for llama runner to start responding"
2025-02-16T06:10:14.784177+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.784Z level=INFO source=server.go:589 msg="waiting for server to become available" status="llm server error"
2025-02-16T06:10:14.837712+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.837Z level=INFO source=runner.go:936 msg="starting go runner"
2025-02-16T06:10:14.851022+00:00 ollama-prod ollama[3829]: ggml_cuda_init: GGML_CUDA_FORCE_MMQ: no
2025-02-16T06:10:14.851091+00:00 ollama-prod ollama[3829]: ggml_cuda_init: GGML_CUDA_FORCE_CUBLAS: no
2025-02-16T06:10:14.851127+00:00 ollama-prod ollama[3829]: ggml_cuda_init: found 1 CUDA devices:
2025-02-16T06:10:14.853040+00:00 ollama-prod ollama[3829]: Device 0: NVIDIA A100-SXM4-80GB, compute capability 8.0, VMM: yes
2025-02-16T06:10:14.857103+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.856Z level=INFO source=runner.go:937 msg=system info="CUDA : ARCHS = 600,610,620,700,720,750,800,860,870,890,900 | USE_GRAPHS = 1 | PEER_MAX_BATCH_SIZE = 128
| CPU : SSE3 = 1 | SSSE3 = 1 | AVX = 1 | LLAMAFILE = 1 | AARCH64_REPACK = 1 | cgo(gcc)" threads=6
2025-02-16T06:10:14.857380+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.857Z level=INFO source=.:0 msg="Server listening on 127.0.0.1:36267"
2025-02-16T06:10:15.035815+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:15.035Z level=INFO source=server.go:589 msg="waiting for server to become available" status="llm server loading model"
2025-02-16T06:10:15.086444+00:00 ollama-prod ollama[3829]: llama_load_model_from_file: using device CUDA0 (NVIDIA A100-SXM4-80GB) - 75056 MiB free
2025-02-16T06:10:15.148049+00:00 ollama-prod ollama[3829]: llama_model_loader: loaded meta data with 29 key-value pairs and 724 tensors from /data/ollama/models/blobs/sha256-a677b4a4b70c45e702b1d600f7905e367733c53898b8be60e3f29272cf334574 (ve
rsion GGUF V3 (latest))
2025-02-16T06:10:15.148231+00:00 ollama-prod ollama[3829]: llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
2025-02-16T06:10:15.148283+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 0: general.architecture str = llama
2025-02-16T06:10:15.148318+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 1: general.type str = model
2025-02-16T06:10:15.148350+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 2: general.name str = Meta Llama 3.1 70B Instruct
2025-02-16T06:10:15.148397+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 3: general.finetune str = Instruct
2025-02-16T06:10:15.148431+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 4: general.basename str = Meta-Llama-3.1
2025-02-16T06:10:15.148463+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 5: general.size_label str = 70B
2025-02-16T06:10:15.148495+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 6: general.license str = llama3.1

looks like because of the competition for CPU and GPU memory resources.

Is there any way to fix or avoid this issue?

Originally created by @saeya211 on GitHub (Feb 17, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9168 # ollama info: version: config: OLLAMA_MAX_LOADED_MODELS = 3 for example: ollama ps shows three models: model-A, model-B, model-C. These models are used at the same time, like user1 is chating with model-A, user2 is chating with model-B, user3 is chating with model-C User4 wanna to chat with model-D now, then the issue will happen. ERROR log: 2025-02-16T06:10:14.783407+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.783Z level=INFO source=server.go:376 msg="starting llama server" cmd="/usr/local/lib/ollama/runners/cuda_v12_avx/ollama_llama_server runner --model /data/olla ma/models/blobs/sha256-a677b4a4b70c45e702b1d600f7905e367733c53898b8be60e3f29272cf334574 --ctx-size 8192 --batch-size 512 --n-gpu-layers 81 --threads 6 --parallel 4 --port 36267" 2025-02-16T06:10:14.783779+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.783Z level=INFO source=sched.go:449 msg="loaded runners" count=2 2025-02-16T06:10:14.783831+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.783Z level=INFO source=server.go:555 msg="waiting for llama runner to start responding" 2025-02-16T06:10:14.784177+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.784Z level=INFO source=server.go:589 msg="waiting for server to become available" status="llm server error" 2025-02-16T06:10:14.837712+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.837Z level=INFO source=runner.go:936 msg="starting go runner" 2025-02-16T06:10:14.851022+00:00 ollama-prod ollama[3829]: ggml_cuda_init: GGML_CUDA_FORCE_MMQ: no 2025-02-16T06:10:14.851091+00:00 ollama-prod ollama[3829]: ggml_cuda_init: GGML_CUDA_FORCE_CUBLAS: no 2025-02-16T06:10:14.851127+00:00 ollama-prod ollama[3829]: ggml_cuda_init: found 1 CUDA devices: 2025-02-16T06:10:14.853040+00:00 ollama-prod ollama[3829]: Device 0: NVIDIA A100-SXM4-80GB, compute capability 8.0, VMM: yes 2025-02-16T06:10:14.857103+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.856Z level=INFO source=runner.go:937 msg=system info="CUDA : ARCHS = 600,610,620,700,720,750,800,860,870,890,900 | USE_GRAPHS = 1 | PEER_MAX_BATCH_SIZE = 128 | CPU : SSE3 = 1 | SSSE3 = 1 | AVX = 1 | LLAMAFILE = 1 | AARCH64_REPACK = 1 | cgo(gcc)" threads=6 2025-02-16T06:10:14.857380+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.857Z level=INFO source=.:0 msg="Server listening on 127.0.0.1:36267" 2025-02-16T06:10:15.035815+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:15.035Z level=INFO source=server.go:589 msg="waiting for server to become available" status="llm server loading model" 2025-02-16T06:10:15.086444+00:00 ollama-prod ollama[3829]: llama_load_model_from_file: using device CUDA0 (NVIDIA A100-SXM4-80GB) - 75056 MiB free 2025-02-16T06:10:15.148049+00:00 ollama-prod ollama[3829]: llama_model_loader: loaded meta data with 29 key-value pairs and 724 tensors from /data/ollama/models/blobs/sha256-a677b4a4b70c45e702b1d600f7905e367733c53898b8be60e3f29272cf334574 (ve rsion GGUF V3 (latest)) 2025-02-16T06:10:15.148231+00:00 ollama-prod ollama[3829]: llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output. 2025-02-16T06:10:15.148283+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 0: general.architecture str = llama 2025-02-16T06:10:15.148318+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 1: general.type str = model 2025-02-16T06:10:15.148350+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 2: general.name str = Meta Llama 3.1 70B Instruct 2025-02-16T06:10:15.148397+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 3: general.finetune str = Instruct 2025-02-16T06:10:15.148431+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 4: general.basename str = Meta-Llama-3.1 2025-02-16T06:10:15.148463+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 5: general.size_label str = 70B 2025-02-16T06:10:15.148495+00:00 ollama-prod ollama[3829]: llama_model_loader: - kv 6: general.license str = llama3.1 looks like because of the competition for CPU and GPU memory resources. Is there any way to fix or avoid this issue?
GiteaMirror added the feature request label 2026-04-22 12:26:53 -05:00
Author
Owner

@rick-github commented on GitHub (Feb 17, 2025):

I don't see any errors here. If you mean this line:

2025-02-16T06:10:14.784177+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.784Z level=INFO source=server.go:589 msg="waiting for server to become available" status="llm server error"

llm server error is a poorly named state, in context it really means I'm about to load the server.

<!-- gh-comment-id:2662752083 --> @rick-github commented on GitHub (Feb 17, 2025): I don't see any errors here. If you mean this line: ``` 2025-02-16T06:10:14.784177+00:00 ollama-prod ollama[3829]: time=2025-02-16T06:10:14.784Z level=INFO source=server.go:589 msg="waiting for server to become available" status="llm server error" ``` `llm server error` is a poorly named state, in context it really means `I'm about to load the server`.
Author
Owner

@saeya211 commented on GitHub (Feb 17, 2025):

Thanks for reply.
However, the chat page of OpenWebui reports a network err error, which may be a configuration problem of OpenWebui. Let's ignore this for now if "llm server error" really means "I'm about to load the server"

Let's take the above scenario as an example.
Assuming that the GPU memory of the Ollama machine is 156G in total, and the SIZEs of the four models are 20G(model-A), 40G(model-B), 42G(model-C), and 140G(model-D) respectively, will the call to model-D fail due to resource competition?

What is the scheduling mechanism of the model in this case? Can you give an example?

<!-- gh-comment-id:2662814049 --> @saeya211 commented on GitHub (Feb 17, 2025): Thanks for reply. However, the chat page of OpenWebui reports a network err error, which may be a configuration problem of OpenWebui. Let's ignore this for now if "llm server error" really means "I'm about to load the server" Let's take the above scenario as an example. Assuming that the GPU memory of the Ollama machine is 156G in total, and the SIZEs of the four models are 20G(model-A), 40G(model-B), 42G(model-C), and 140G(model-D) respectively, will the call to model-D fail due to resource competition? What is the scheduling mechanism of the model in this case? Can you give an example?
Author
Owner

@rick-github commented on GitHub (Feb 17, 2025):

The call to model-D should not fail. The other models should be unloaded to make room. If you post more of the logs we can verify.

<!-- gh-comment-id:2662831138 --> @rick-github commented on GitHub (Feb 17, 2025): The call to model-D should not fail. The other models should be unloaded to make room. If you post more of the logs we can verify.
Author
Owner

@saeya211 commented on GitHub (Feb 18, 2025):

There is no more err logs.

Just wanna to know what happen if some corner case occur, like:
model-A&B&C keep thinking for 30s or more, and model-D is called at the same time.
Will model-D keep waiting to be loaded until the call to model-A&B&C are finished ?

<!-- gh-comment-id:2664476158 --> @saeya211 commented on GitHub (Feb 18, 2025): There is no more err logs. Just wanna to know what happen if some corner case occur, like: model-A&B&C keep thinking for 30s or more, and model-D is called at the same time. Will model-D keep waiting to be loaded until the call to model-A&B&C are finished ?
Author
Owner

@rick-github commented on GitHub (Feb 18, 2025):

Yes.

<!-- gh-comment-id:2664953827 --> @rick-github commented on GitHub (Feb 18, 2025): Yes.
Author
Owner

@saeya211 commented on GitHub (Feb 19, 2025):

Thanks a lot.

<!-- gh-comment-id:2667343618 --> @saeya211 commented on GitHub (Feb 19, 2025): Thanks a lot.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#31728