package proc import ( "analysis/logo" "basic.com/valib/gogpu.git" ) func freeGPU(id, needed, reserve int) int { indices := gogpu.RankGPU() if len(indices) == 0 { logo.Errorln("THERE IS NO GPU FOR VALID") return -2 } gi := id if id == -1 { if !gogpu.SatisfyGPU(indices[0], needed, reserve) { logo.Errorf("CAN'T SPARE GPU MEMORY NEEDED : %dM, RESERVER: %dM\n", needed, reserve) gi = -1 } gi = indices[0] } else { if !gogpu.SatisfyGPU(gi, needed, reserve) { logo.Errorf("2ND CAN'T SPARE GPU MEMORY NEEDED : %dM, RESERVER: %dM\n", needed, reserve) gi = indices[0] if !gogpu.SatisfyGPU(gi, needed, reserve) { logo.Errorf("3RD CAN'T SPARE GPU MEMORY NEEDED : %dM, RESERVER: %dM\n", needed, reserve) gi = -1 } } } return gi } // 优先不使用第1快显卡 func priorGPU(lastChoice, needed, reserve int) int { indices := gogpu.RankGPU() if len(indices) == 0 { return -1 } for _, v := range indices { if v != lastChoice { if gogpu.SatisfyGPU(v, needed, reserve) { return v } } } if gogpu.SatisfyGPU(lastChoice, needed, reserve) { return lastChoice } return -1 }