only check system memory on macos

This commit is contained in:
Michael Yang 2023-10-13 14:41:51 -07:00
parent 4a8931f634
commit 36fe2deebf

View file

@ -56,7 +56,6 @@ func New(workDir, model string, adapters []string, opts api.Options) (LLM, error
opts.NumGPU = 0
}
}
}
var requiredMemory int64
var f16Multiplier int64 = 2
@ -77,18 +76,12 @@ func New(workDir, model string, adapters []string, opts api.Options) (LLM, error
systemMemory := int64(memory.TotalMemory())
videoMemory, err := CheckVRAM()
if err != nil{
videoMemory = 0
}
totalMemory := systemMemory + videoMemory
if ggml.FileType() == "F16" && requiredMemory*f16Multiplier > totalMemory {
if ggml.FileType() == "F16" && requiredMemory*f16Multiplier > systemMemory {
return nil, fmt.Errorf("F16 model requires at least %s of total memory", format.HumanBytes(requiredMemory))
} else if requiredMemory > totalMemory {
} else if requiredMemory > systemMemory {
return nil, fmt.Errorf("model requires at least %s of total memory", format.HumanBytes(requiredMemory))
}
}
switch ggml.Name() {
case "gguf":