mirror of
https://github.com/mudler/LocalAI.git
synced 2024-12-24 14:56:41 +00:00
feat(backend): fallback with autodetect (#2693)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
ad85c5a1e7
commit
bd2f95c130
@ -509,6 +509,27 @@ func (ml *ModelLoader) GreedyLoader(opts ...Option) (grpc.Backend, error) {
|
|||||||
err = errors.Join(err, fmt.Errorf("backend %s returned no usable model", key))
|
err = errors.Join(err, fmt.Errorf("backend %s returned no usable model", key))
|
||||||
log.Info().Msgf("[%s] Fails: %s", key, "backend returned no usable model")
|
log.Info().Msgf("[%s] Fails: %s", key, "backend returned no usable model")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if autoDetect && key == LLamaCPP && err != nil {
|
||||||
|
backendToUse := LLamaCPPFallback
|
||||||
|
if xsysinfo.HasCPUCaps(cpuid.AVX2) {
|
||||||
|
backendToUse = LLamaCPPAVX2
|
||||||
|
} else if xsysinfo.HasCPUCaps(cpuid.AVX) {
|
||||||
|
backendToUse = LLamaCPPAVX
|
||||||
|
}
|
||||||
|
|
||||||
|
// Autodetection failed, try the fallback
|
||||||
|
log.Info().Msgf("[%s] Autodetection failed, trying the fallback", key)
|
||||||
|
options = append(options, WithBackendString(backendToUse))
|
||||||
|
model, modelerr = ml.BackendLoader(options...)
|
||||||
|
if modelerr == nil && model != nil {
|
||||||
|
log.Info().Msgf("[%s] Loads OK", key)
|
||||||
|
return model, nil
|
||||||
|
} else {
|
||||||
|
err = errors.Join(err, fmt.Errorf("[%s]: %w", key, modelerr))
|
||||||
|
log.Info().Msgf("[%s] Fails: %s", key, modelerr.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("could not load model - all backends returned error: %s", err.Error())
|
return nil, fmt.Errorf("could not load model - all backends returned error: %s", err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user