mirror of
https://github.com/zebrajr/ollama.git
synced 2025-12-06 00:19:51 +01:00
llm: Avoid underflow in free memory logging
If a GPU's free memory is less than the reserved amount, we might get an underflow. Since it is an unsigned uint64, we print this as a large number rather than the more correct 0. This only affects logging, the actual layout code already handles this correctly. Bug #12138
This commit is contained in:
parent
0cc90a8186
commit
8149a3c86e
|
|
@ -678,8 +678,12 @@ func (s *ollamaServer) Load(ctx context.Context, gpus discover.GpuInfoList, requ
|
||||||
|
|
||||||
if !(len(gpus) == 1 && gpus[0].Library == "cpu") {
|
if !(len(gpus) == 1 && gpus[0].Library == "cpu") {
|
||||||
for _, gpu := range gpus {
|
for _, gpu := range gpus {
|
||||||
|
available := gpu.FreeMemory - envconfig.GpuOverhead() - gpu.MinimumMemory
|
||||||
|
if gpu.FreeMemory < envconfig.GpuOverhead()+gpu.MinimumMemory {
|
||||||
|
available = 0
|
||||||
|
}
|
||||||
slog.Info("gpu memory", "id", gpu.ID,
|
slog.Info("gpu memory", "id", gpu.ID,
|
||||||
"available", format.HumanBytes2(gpu.FreeMemory-envconfig.GpuOverhead()-gpu.MinimumMemory),
|
"available", format.HumanBytes2(available),
|
||||||
"free", format.HumanBytes2(gpu.FreeMemory),
|
"free", format.HumanBytes2(gpu.FreeMemory),
|
||||||
"minimum", format.HumanBytes2(gpu.MinimumMemory),
|
"minimum", format.HumanBytes2(gpu.MinimumMemory),
|
||||||
"overhead", format.HumanBytes2(envconfig.GpuOverhead()))
|
"overhead", format.HumanBytes2(envconfig.GpuOverhead()))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user