v0.0.7 - 更新支持查询GPU信息

This commit is contained in:
spiritlhl
2024-07-28 13:03:04 +00:00
parent 3a3f46d5cc
commit 58e26753bb
19 changed files with 894 additions and 7 deletions

27
system/gpu/gpu.go Normal file
View File

@@ -0,0 +1,27 @@
//go:build !darwin
// +build !darwin
package gpu
import (
"errors"
"github.com/jaypipes/ghw"
)
func GetGPUModel() ([]string, error) {
var gpuModel []string
gi, err := ghw.GPU(ghw.WithDisableWarnings())
if err != nil {
return nil, err
}
for _, card := range gi.GraphicsCards {
if card.DeviceInfo == nil {
return nil, errors.New("Cannot find device info")
}
gpuModel = append(gpuModel, card.DeviceInfo.Product.Name)
}
return gpuModel, nil
}