lotus/lib/harmony/resources/getGPU.go

23 lines
464 B
Go
Raw Normal View History

2023-10-31 22:13:16 +00:00
//go:build !darwin
// +build !darwin
package resources
import (
"strings"
ffi "github.com/filecoin-project/filecoin-ffi"
)
func getGPUDevices() float64 { // GPU boolean
gpus, err := ffi.GetGPUDevices()
if err != nil {
logger.Errorf("getting gpu devices failed: %+v", err)
}
all := strings.ToLower(strings.Join(gpus, ","))
if len(gpus) > 1 || strings.Contains(all, "ati") || strings.Contains(all, "nvidia") {
return float64(len(gpus))
}
2023-11-02 16:03:30 +00:00
return 0
2023-10-31 22:13:16 +00:00
}