[GH-ISSUE #5908] GPU ID initialization incorrect - CPUs not always first in list #3687

Closed
opened 2026-04-12 14:30:13 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @7910f6ba7ee4 on GitHub (Jul 24, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/5908

Originally assigned to: @dhiltgen on GitHub.

What is the issue?

In amd_linux.go, it is assumed that "CPUs are always first in the list" when calculating the gpu id:

// CPUs are always first in the list
gpuID := nodeID - cpuCount

however, this is not always the case when the number of topology nodes is greater than 10 (which I unfortunately have), as this results in, for example, the node ids (0, 1, 10, 11, 2, 3...), as the file glob returns things alphabetically. This is a problem when nodes 0-3 are CPUs and 4-11 are GPUs, as 10,11 get set to 8,9 with the current implementation, which results in a gap for gpu ids 6-7.

I am guessing this could be solved though a natural sorting of the list of filename strings before looping through them, or by first calculating all cpu ids before offsetting the gpu ids by the cpu count.

OS

Linux

GPU

AMD

CPU

No response

Ollama version

0.2.1

Originally created by @7910f6ba7ee4 on GitHub (Jul 24, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/5908 Originally assigned to: @dhiltgen on GitHub. ### What is the issue? In `amd_linux.go`, it is assumed that "CPUs are always first in the list" when calculating the gpu id: ``` // CPUs are always first in the list gpuID := nodeID - cpuCount ``` however, this is not always the case when the number of topology nodes is greater than 10 (which I unfortunately have), as this results in, for example, the node ids (0, 1, 10, 11, 2, 3...), as the file glob returns things alphabetically. This is a problem when nodes 0-3 are CPUs and 4-11 are GPUs, as 10,11 get set to 8,9 with the current implementation, which results in a gap for gpu ids 6-7. I am guessing this could be solved though a natural sorting of the list of filename strings before looping through them, or by first calculating all cpu ids before offsetting the gpu ids by the cpu count. ### OS Linux ### GPU AMD ### CPU _No response_ ### Ollama version 0.2.1
GiteaMirror added the linuxamdbug labels 2026-04-12 14:30: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#3687