Skip to content

Commit

Permalink
experiment: GPU Overprovisioning (#262)
Browse files Browse the repository at this point in the history
* experiment: GPU Overprovisioning

* make gen
  • Loading branch information
magik6k authored Oct 16, 2024
1 parent 4452678 commit d71f3c6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
17 changes: 15 additions & 2 deletions harmony/resources/getGPU.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ import (
ffi "github.com/filecoin-project/filecoin-ffi"
)

var GpuOverprovisionFactor = 1

func init() {
if nstr := os.Getenv("HARMONY_GPU_OVERPROVISION_FACTOR"); nstr != "" {
n, err := strconv.Atoi(nstr)
if err != nil {
logger.Errorf("parsing HARMONY_GPU_OVERPROVISION_FACTOR failed: %+v", err)
} else {
GpuOverprovisionFactor = n
}
}
}

func getGPUDevices() float64 { // GPU boolean
if nstr := os.Getenv("HARMONY_OVERRIDE_GPUS"); nstr != "" {
n, err := strconv.ParseFloat(nstr, 64)
Expand All @@ -22,13 +35,13 @@ func getGPUDevices() float64 { // GPU boolean
}

gpus, err := ffi.GetGPUDevices()
logger.Infow("GPUs", "list", gpus)
logger.Infow("GPUs", "list", gpus, "overprovision_factor", GpuOverprovisionFactor)
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))
return float64(len(gpus) * GpuOverprovisionFactor)
}
return 0
}
9 changes: 6 additions & 3 deletions lib/ffiselect/ffiselect.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/filecoin-project/go-state-types/proof"

"github.com/filecoin-project/curio/build"
"github.com/filecoin-project/curio/harmony/resources"
"github.com/filecoin-project/curio/lib/storiface"
)

Expand All @@ -45,9 +46,11 @@ func init() {
ch = make(chan string, 1)
ch <- "0"
} else {
ch = make(chan string, len(devices))
for i := 0; i < len(devices); i++ {
ch <- strconv.Itoa(i)
nSlots := len(devices) * resources.GpuOverprovisionFactor

ch = make(chan string, nSlots)
for i := 0; i < nSlots; i++ {
ch <- strconv.Itoa(i / resources.GpuOverprovisionFactor)
}
}
}
Expand Down

0 comments on commit d71f3c6

Please sign in to comment.