fix metal gpu

This commit is contained in:
Michael Yang 2024-04-02 16:06:45 -07:00
parent a57818d93e
commit 80163ebcb5

View file

@ -85,7 +85,7 @@ func NewLlamaServer(model string, adapters, projectors []string, opts *api.Optio
graph := int64(ggml.KV().GQA()) * kv / 6 graph := int64(ggml.KV().GQA()) * kv / 6
usedMemory += graph usedMemory += graph
if usedMemory > availableMemory || slices.Contains(cpuOnlyFamilies, ggml.KV().Architecture()) { if (usedMemory > availableMemory || slices.Contains(cpuOnlyFamilies, ggml.KV().Architecture())) && info.Library != "metal" {
info.Library = "cpu" info.Library = "cpu"
} }
@ -159,7 +159,7 @@ func NewLlamaServer(model string, adapters, projectors []string, opts *api.Optio
params = append(params, "--log-disable") params = append(params, "--log-disable")
} }
if opts.NumGPU > 0 { if opts.NumGPU >= 0 {
params = append(params, "--n-gpu-layers", fmt.Sprintf("%d", opts.NumGPU)) params = append(params, "--n-gpu-layers", fmt.Sprintf("%d", opts.NumGPU))
} }