feat(startup): show CPU/GPU information with --debug (#2241)

Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto 2024-05-05 09:10:23 +02:00 committed by GitHub
parent 117c9873e1
commit b69ff46c7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 95 additions and 3 deletions

38
pkg/xsysinfo/cpu.go Normal file
View 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...)
}