[GH-ISSUE #8947] How to enable data-parallel inference with multi-GPU? #5804

Closed
opened 2026-04-12 17:08:48 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @lixiangge on GitHub (Feb 8, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/8947

I’m currently using Ollama with docker to deploy Qwen2.5 on a single GPU, and it works well. However, inference speed is a bottleneck when processing large amounts of data. Since I have four GPUs available, I would like to parallelize the inference process by using all four GPUs, in a way similar to data parallelism.
My idea is to load a full copy of the model on each GPU and have each GPU process 1/4 of the total input data independently. This should allow me to speed up inference by utilizing all available GPUs.
I haven’t found a clear way to achieve this in Ollama. Is there an existing feature or a recommended approach to enable this kind of multi-GPU inference? If not, are there any workarounds or best practices that you would suggest?
Any guidance or insights would be greatly appreciated!
Thanks in advance.

Originally created by @lixiangge on GitHub (Feb 8, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/8947 I’m currently using Ollama with docker to deploy Qwen2.5 on a single GPU, and it works well. However, inference speed is a bottleneck when processing large amounts of data. Since I have four GPUs available, I would like to parallelize the inference process by using all four GPUs, in a way similar to data parallelism. My idea is to load a full copy of the model on each GPU and have each GPU process 1/4 of the total input data independently. This should allow me to speed up inference by utilizing all available GPUs. I haven’t found a clear way to achieve this in Ollama. Is there an existing feature or a recommended approach to enable this kind of multi-GPU inference? If not, are there any workarounds or best practices that you would suggest? Any guidance or insights would be greatly appreciated! Thanks in advance.
GiteaMirror added the feature request label 2026-04-12 17:08:48 -05:00
Author
Owner

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

Run four ollama servers, and set CUDA_VISIBLE_DEVICES to a different GPU for each server. Run a proxy server in front to present a unified interface (eg litellm, ollama_proxy, nginx).

<!-- gh-comment-id:2644743656 --> @rick-github commented on GitHub (Feb 8, 2025): Run four ollama servers, and set [`CUDA_VISIBLE_DEVICES`](https://github.com/ollama/ollama/blob/main/docs/gpu.md#gpu-selection) to a different GPU for each server. Run a proxy server in front to present a unified interface (eg [litellm](https://github.com/BerriAI/litellm), [ollama_proxy](https://github.com/ParisNeo/ollama_proxy_server), [nginx](https://github.com/ollama/ollama/issues/8186#issuecomment-2560443545)).
Author
Owner

@lixiangge commented on GitHub (Feb 16, 2025):

@rick-github
Thanks,it works!

<!-- gh-comment-id:2661188445 --> @lixiangge commented on GitHub (Feb 16, 2025): @rick-github Thanks,it works!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5804