modified ai option
Former-commit-id: dc33df489a557efeecabb26e01f422b97311212a
This commit is contained in:
parent
bfe7597644
commit
7487707f3d
|
@ -2,6 +2,7 @@ package option
|
||||||
|
|
||||||
type AiOption struct {
|
type AiOption struct {
|
||||||
AiClusterId string // shuguangAi /octopus ClusterId
|
AiClusterId string // shuguangAi /octopus ClusterId
|
||||||
|
TaskName string
|
||||||
ResourceType string // cpu/gpu/compute card
|
ResourceType string // cpu/gpu/compute card
|
||||||
TaskType string // pytorch/tensorflow/mindspore
|
TaskType string // pytorch/tensorflow/mindspore
|
||||||
DatasetsName string // mnist/imageNet/iris
|
DatasetsName string // mnist/imageNet/iris
|
||||||
|
@ -10,6 +11,7 @@ type AiOption struct {
|
||||||
Tops float64
|
Tops float64
|
||||||
ComputeCard string
|
ComputeCard string
|
||||||
CodeType string
|
CodeType string
|
||||||
|
AlgorithmName string
|
||||||
|
|
||||||
ImageId string
|
ImageId string
|
||||||
SpecId string
|
SpecId string
|
||||||
|
@ -22,7 +24,8 @@ type AiOption struct {
|
||||||
Envs []string
|
Envs []string
|
||||||
Params []string
|
Params []string
|
||||||
|
|
||||||
Datasets string
|
Datasets string
|
||||||
Code string
|
AlgorithmCode string
|
||||||
Model interface{}
|
Image string
|
||||||
|
Model interface{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,91 +351,7 @@ func (o *OctopusLink) generateResourceId(option *option.AiOption) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return errors.New("failed to get ResourceId")
|
||||||
}
|
|
||||||
|
|
||||||
func setResourceIdByCard(option *option.AiOption, specs *octopus.GetResourceSpecsResp, computeCard string) error {
|
|
||||||
if option.Tops == 0 {
|
|
||||||
for _, spec := range specs.TrainResourceSpecs {
|
|
||||||
if spec.Price == 1 {
|
|
||||||
ns := strings.Split(spec.Name, COMMA)
|
|
||||||
cardSpecs := strings.Split(ns[0], STAR)
|
|
||||||
if cardSpecs[1] == computeCard {
|
|
||||||
option.ResourceId = spec.Id
|
|
||||||
option.ComputeCard = computeCard
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cardNum := math.Ceil(option.Tops / float64(BASE_TOPS))
|
|
||||||
for _, spec := range specs.TrainResourceSpecs {
|
|
||||||
if option.Tops < BASE_TOPS {
|
|
||||||
if spec.Price == 1 {
|
|
||||||
ns := strings.Split(spec.Name, COMMA)
|
|
||||||
cardSpecs := strings.Split(ns[0], STAR)
|
|
||||||
if cardSpecs[1] == computeCard {
|
|
||||||
option.ResourceId = spec.Id
|
|
||||||
option.ComputeCard = computeCard
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ns := strings.Split(spec.Name, COMMA)
|
|
||||||
if len(ns) != 4 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
cardSpecs := strings.Split(ns[0], STAR)
|
|
||||||
if cardSpecs[1] != computeCard {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
s, err := strconv.ParseFloat(cardSpecs[0], 64)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
switch computeCard {
|
|
||||||
case GCU:
|
|
||||||
if cardNum == s { // 1, 4, 8
|
|
||||||
option.ResourceId = spec.Id
|
|
||||||
option.ComputeCard = computeCard
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if 1 < cardNum && cardNum <= 4 && s == 4 {
|
|
||||||
option.ResourceId = spec.Id
|
|
||||||
option.ComputeCard = computeCard
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if 4 < cardNum && s == 8 {
|
|
||||||
option.ResourceId = spec.Id
|
|
||||||
option.ComputeCard = computeCard
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
case MLU: // 1, 2, 4
|
|
||||||
if cardNum/2 == s {
|
|
||||||
option.ResourceId = spec.Id
|
|
||||||
option.ComputeCard = computeCard
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if 1 < cardNum/2 && cardNum/2 <= 2 && s == 2 {
|
|
||||||
option.ResourceId = spec.Id
|
|
||||||
option.ComputeCard = computeCard
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if 2 < cardNum/2 && s == 4 {
|
|
||||||
option.ResourceId = spec.Id
|
|
||||||
option.ComputeCard = computeCard
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return errors.New("set ResourceId error")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) generateDatasetsId(option *option.AiOption) error {
|
func (o *OctopusLink) generateDatasetsId(option *option.AiOption) error {
|
||||||
|
@ -552,3 +468,87 @@ func (o *OctopusLink) generateParams(option *option.AiOption) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setResourceIdByCard(option *option.AiOption, specs *octopus.GetResourceSpecsResp, computeCard string) error {
|
||||||
|
if option.Tops == 0 {
|
||||||
|
for _, spec := range specs.TrainResourceSpecs {
|
||||||
|
if spec.Price == 1 {
|
||||||
|
ns := strings.Split(spec.Name, COMMA)
|
||||||
|
cardSpecs := strings.Split(ns[0], STAR)
|
||||||
|
if cardSpecs[1] == computeCard {
|
||||||
|
option.ResourceId = spec.Id
|
||||||
|
option.ComputeCard = computeCard
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cardNum := math.Ceil(option.Tops / float64(BASE_TOPS))
|
||||||
|
for _, spec := range specs.TrainResourceSpecs {
|
||||||
|
if option.Tops < BASE_TOPS {
|
||||||
|
if spec.Price == 1 {
|
||||||
|
ns := strings.Split(spec.Name, COMMA)
|
||||||
|
cardSpecs := strings.Split(ns[0], STAR)
|
||||||
|
if cardSpecs[1] == computeCard {
|
||||||
|
option.ResourceId = spec.Id
|
||||||
|
option.ComputeCard = computeCard
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ns := strings.Split(spec.Name, COMMA)
|
||||||
|
if len(ns) != 4 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
cardSpecs := strings.Split(ns[0], STAR)
|
||||||
|
if cardSpecs[1] != computeCard {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
s, err := strconv.ParseFloat(cardSpecs[0], 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch computeCard {
|
||||||
|
case GCU:
|
||||||
|
if cardNum == s { // 1, 4, 8
|
||||||
|
option.ResourceId = spec.Id
|
||||||
|
option.ComputeCard = computeCard
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if 1 < cardNum && cardNum <= 4 && s == 4 {
|
||||||
|
option.ResourceId = spec.Id
|
||||||
|
option.ComputeCard = computeCard
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if 4 < cardNum && s == 8 {
|
||||||
|
option.ResourceId = spec.Id
|
||||||
|
option.ComputeCard = computeCard
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
case MLU: // 1, 2, 4
|
||||||
|
if cardNum/2 == s {
|
||||||
|
option.ResourceId = spec.Id
|
||||||
|
option.ComputeCard = computeCard
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if 1 < cardNum/2 && cardNum/2 <= 2 && s == 2 {
|
||||||
|
option.ResourceId = spec.Id
|
||||||
|
option.ComputeCard = computeCard
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if 2 < cardNum/2 && s == 4 {
|
||||||
|
option.ResourceId = spec.Id
|
||||||
|
option.ComputeCard = computeCard
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return errors.New("set ResourceId error")
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ const (
|
||||||
RAM_SIZE_1G = 1024 // 1G
|
RAM_SIZE_1G = 1024 // 1G
|
||||||
WORKER_NUMBER = 1
|
WORKER_NUMBER = 1
|
||||||
DCU = "dcu"
|
DCU = "dcu"
|
||||||
|
DCU_TOPS = 24.5
|
||||||
PYTORCH = "Pytorch"
|
PYTORCH = "Pytorch"
|
||||||
TASK_PYTORCH_PREFIX = "PytorchTask"
|
TASK_PYTORCH_PREFIX = "PytorchTask"
|
||||||
TENSORFLOW = "Tensorflow"
|
TENSORFLOW = "Tensorflow"
|
||||||
|
@ -345,8 +346,27 @@ func (s *ShuguangAi) GenerateSubmitParams(option *option.AiOption) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShuguangAi) generateResourceId(option *option.AiOption) error {
|
func (s *ShuguangAi) generateResourceId(option *option.AiOption) error {
|
||||||
|
if option.ResourceType == "" {
|
||||||
|
return errors.New("ResourceType not set")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
if option.ResourceType == CPU {
|
||||||
|
option.ResourceId = "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi"
|
||||||
|
}
|
||||||
|
|
||||||
|
if option.ResourceType == CARD {
|
||||||
|
if option.Tops == 0 {
|
||||||
|
option.ResourceId = "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi"
|
||||||
|
}
|
||||||
|
|
||||||
|
if option.Tops > DCU_TOPS {
|
||||||
|
option.ResourceId = "jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2"
|
||||||
|
}
|
||||||
|
|
||||||
|
//Todo add more dcu specs
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors.New("failed to get ResourceId")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShuguangAi) generateImageId(option *option.AiOption) error {
|
func (s *ShuguangAi) generateImageId(option *option.AiOption) error {
|
||||||
|
@ -365,7 +385,12 @@ func (s *ShuguangAi) generateImageId(option *option.AiOption) error {
|
||||||
if resp.Code != "0" {
|
if resp.Code != "0" {
|
||||||
return errors.New("failed to get imageId")
|
return errors.New("failed to get imageId")
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
if option.ResourceType == CPU {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors.New("failed to get ImageId")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShuguangAi) generateAlgorithmId(option *option.AiOption) error {
|
func (s *ShuguangAi) generateAlgorithmId(option *option.AiOption) error {
|
||||||
|
|
Loading…
Reference in New Issue