mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-30 15:35:01 +00:00
feat(startup): show CPU/GPU information with --debug (#2241)
Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
parent
117c9873e1
commit
b69ff46c7e
6 changed files with 95 additions and 3 deletions
|
@ -48,8 +48,11 @@ func backendPath(assetDir, backend string) string {
|
|||
return filepath.Join(assetDir, "backend-assets", "grpc", backend)
|
||||
}
|
||||
|
||||
// backendsInAssetDir returns the list of backends in the asset directory
|
||||
// that should be loaded
|
||||
func backendsInAssetDir(assetDir string) ([]string, error) {
|
||||
excludeBackends := []string{"local-store"}
|
||||
// Exclude backends from automatic loading
|
||||
excludeBackends := []string{LocalStoreBackend}
|
||||
entry, err := os.ReadDir(backendPath(assetDir, ""))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -70,7 +73,6 @@ ENTRY:
|
|||
// order backends from the asset directory.
|
||||
// as we scan for backends, we want to keep some order which backends are tried of.
|
||||
// for example, llama.cpp should be tried first, and we want to keep the huggingface backend at the last.
|
||||
|
||||
// sets a priority list
|
||||
// First has more priority
|
||||
priorityList := []string{
|
||||
|
|
38
pkg/xsysinfo/cpu.go
Normal file
38
pkg/xsysinfo/cpu.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package xsysinfo
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/jaypipes/ghw"
|
||||
"github.com/klauspost/cpuid/v2"
|
||||
)
|
||||
|
||||
func CPUCapabilities() ([]string, error) {
|
||||
cpu, err := ghw.CPU()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
caps := map[string]struct{}{}
|
||||
|
||||
for _, proc := range cpu.Processors {
|
||||
for _, c := range proc.Capabilities {
|
||||
|
||||
caps[c] = struct{}{}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ret := []string{}
|
||||
for c := range caps {
|
||||
ret = append(ret, c)
|
||||
}
|
||||
|
||||
// order
|
||||
sort.Strings(ret)
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func HasCPUCaps(ids ...cpuid.FeatureID) bool {
|
||||
return cpuid.CPU.Supports(ids...)
|
||||
}
|
15
pkg/xsysinfo/gpu.go
Normal file
15
pkg/xsysinfo/gpu.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package xsysinfo
|
||||
|
||||
import (
|
||||
"github.com/jaypipes/ghw"
|
||||
"github.com/jaypipes/ghw/pkg/gpu"
|
||||
)
|
||||
|
||||
func GPUs() ([]*gpu.GraphicsCard, error) {
|
||||
gpu, err := ghw.GPU()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return gpu.GraphicsCards, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue