2023-10-31 22:13:16 +00:00
|
|
|
//go:build !darwin
|
|
|
|
// +build !darwin
|
|
|
|
|
|
|
|
package resources
|
|
|
|
|
|
|
|
import (
|
2024-03-14 13:37:27 +00:00
|
|
|
"os"
|
|
|
|
"strconv"
|
2023-10-31 22:13:16 +00:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
ffi "github.com/filecoin-project/filecoin-ffi"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getGPUDevices() float64 { // GPU boolean
|
2024-03-14 13:37:27 +00:00
|
|
|
if nstr := os.Getenv("HARMONY_OVERRIDE_GPUS"); nstr != "" {
|
|
|
|
n, err := strconv.ParseFloat(nstr, 64)
|
|
|
|
if err != nil {
|
|
|
|
logger.Errorf("parsing HARMONY_OVERRIDE_GPUS failed: %+v", err)
|
|
|
|
} else {
|
|
|
|
return n
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-31 22:13:16 +00:00
|
|
|
gpus, err := ffi.GetGPUDevices()
|
2023-12-20 13:45:19 +00:00
|
|
|
logger.Infow("GPUs", "list", gpus)
|
2023-10-31 22:13:16 +00:00
|
|
|
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
|
|
|
}
|