updated CreateInferDeployInstance logic
Former-commit-id: 3bbf914d3906131d8a71aeac3df0389ad8646d45
This commit is contained in:
parent
dc52eaee49
commit
4f7314a2cd
|
@ -81,6 +81,14 @@ var (
|
||||||
MLU: CAMBRICONMLU290,
|
MLU: CAMBRICONMLU290,
|
||||||
GCU: EnflameT20,
|
GCU: EnflameT20,
|
||||||
}
|
}
|
||||||
|
CardModelNameCmdMap = map[string]map[string]string{
|
||||||
|
BIV100: {"blip-image-captioning-base": "pip install -U transformers; pip install fastapi uvicorn[standard]; pip install python-multipart; cd /code; python infer_biv100.py",
|
||||||
|
"imagenet_resnet50": "pip install -U transformers; pip install fastapi uvicorn[standard]; pip install python-multipart; cd /code/infer; python infer_biv100.py",
|
||||||
|
"chatGLM_6B": "su root; pip install transformers==4.33.2; pip install fastapi uvicorn[standard]; cd /code; python infer_biv100.py"},
|
||||||
|
MLU: {"blip-image-captioning-base": "",
|
||||||
|
"imagenet_resnet50": "su root; . /torch/venv3/pytorch/bin/activate; pip install fastapi uvicorn[standard]; pip install python-multipart; cd /code/infer; python infer_mlu.py",
|
||||||
|
"chatGLM_6B": ""},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewOctopusLink(octopusRpc octopusclient.Octopus, name string, id int64) *OctopusLink {
|
func NewOctopusLink(octopusRpc octopusclient.Octopus, name string, id int64) *OctopusLink {
|
||||||
|
@ -654,7 +662,13 @@ func generateResourceIdForTraining(option *option.AiOption, specResp *octopus.Ge
|
||||||
|
|
||||||
func generateResourceIdForInferDeployInstance(option *option.InferOption, specResp *octopus.GetResourceSpecsResp) error {
|
func generateResourceIdForInferDeployInstance(option *option.InferOption, specResp *octopus.GetResourceSpecsResp) error {
|
||||||
// temporarily use bi-v100
|
// temporarily use bi-v100
|
||||||
cardName := cardCnMap[BIV100]
|
cardName, ok := cardCnMap[BIV100]
|
||||||
|
if !ok {
|
||||||
|
errors.New("computeCard not set")
|
||||||
|
}
|
||||||
|
|
||||||
|
// set computeCard
|
||||||
|
option.ComputeCard = BIV100
|
||||||
|
|
||||||
for _, spec := range specResp.TrainResourceSpecs {
|
for _, spec := range specResp.TrainResourceSpecs {
|
||||||
names := strings.Split(spec.Name, COMMA)
|
names := strings.Split(spec.Name, COMMA)
|
||||||
|
@ -702,6 +716,20 @@ func (o *OctopusLink) generateDatasetsId(ctx context.Context, option *option.AiO
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) generateImageId(ctx context.Context, option *option.AiOption, ifoption *option.InferOption) error {
|
func (o *OctopusLink) generateImageId(ctx context.Context, option *option.AiOption, ifoption *option.InferOption) error {
|
||||||
|
preImgReq := &octopus.GetPresetImageListReq{
|
||||||
|
Platform: o.platform,
|
||||||
|
PageIndex: o.pageIndex,
|
||||||
|
PageSize: o.pageSize,
|
||||||
|
}
|
||||||
|
preImgResp, err := o.octopusRpc.GetPresetImageList(ctx, preImgReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !preImgResp.Success {
|
||||||
|
return errors.New("failed to get PresetImages")
|
||||||
|
}
|
||||||
|
|
||||||
|
if option != nil {
|
||||||
if option.TaskType == "" {
|
if option.TaskType == "" {
|
||||||
return errors.New("TaskType not set")
|
return errors.New("TaskType not set")
|
||||||
}
|
}
|
||||||
|
@ -728,20 +756,6 @@ func (o *OctopusLink) generateImageId(ctx context.Context, option *option.AiOpti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preImgReq := &octopus.GetPresetImageListReq{
|
|
||||||
Platform: o.platform,
|
|
||||||
PageIndex: o.pageIndex,
|
|
||||||
PageSize: o.pageSize,
|
|
||||||
}
|
|
||||||
preImgResp, err := o.octopusRpc.GetPresetImageList(ctx, preImgReq)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !preImgResp.Success {
|
|
||||||
return errors.New("failed to get PresetImages")
|
|
||||||
}
|
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
err = generateImageIdForTraining(option, preImgResp)
|
err = generateImageIdForTraining(option, preImgResp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -873,13 +887,21 @@ func generateAlgorithmIdForTraining(option *option.AiOption, resp *octopus.GetMy
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateAlgorithmIdForInferDeployInstance(option *option.InferOption, resp *octopus.GetMyAlgorithmListResp) error {
|
func generateAlgorithmIdForInferDeployInstance(option *option.InferOption, resp *octopus.GetMyAlgorithmListResp) error {
|
||||||
|
if option.ModelType == "" {
|
||||||
|
return errors.New("ModelType not set")
|
||||||
|
}
|
||||||
|
|
||||||
|
if option.ModelName == "" {
|
||||||
|
return errors.New("ModelName not set")
|
||||||
|
}
|
||||||
|
|
||||||
for _, algorithm := range resp.Payload.Algorithms {
|
for _, algorithm := range resp.Payload.Algorithms {
|
||||||
if strings.Contains(algorithm.AlgorithmName, option.ModelName) {
|
if strings.Contains(algorithm.AlgorithmName, option.ModelName) {
|
||||||
option.AlgorithmId = algorithm.AlgorithmId
|
option.AlgorithmId = algorithm.AlgorithmId
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return errors.New("Algorithm does not exist")
|
return errors.New("ModelName does not exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) generateCmd(option *option.AiOption, ifoption *option.InferOption) error {
|
func (o *OctopusLink) generateCmd(option *option.AiOption, ifoption *option.InferOption) error {
|
||||||
|
@ -919,7 +941,16 @@ func generateCmdForTraining(option *option.AiOption) error {
|
||||||
|
|
||||||
func generateCmdForInferDeployInstance(option *option.InferOption) error {
|
func generateCmdForInferDeployInstance(option *option.InferOption) error {
|
||||||
if option.Cmd == "" {
|
if option.Cmd == "" {
|
||||||
option.Cmd = "su root; pip install fastapi uvicorn[standard]; cd /code/infer; python infer_biv100.py"
|
nameCmd, ok := CardModelNameCmdMap[option.ComputeCard]
|
||||||
|
if !ok {
|
||||||
|
return errors.New("failed to set cmd, ComputeCard not exist")
|
||||||
|
}
|
||||||
|
cmd, ok := nameCmd[option.ModelName]
|
||||||
|
if !ok {
|
||||||
|
return errors.New("failed to set cmd, ModelName not exist")
|
||||||
|
}
|
||||||
|
option.Cmd = cmd
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -1185,7 +1216,7 @@ func (o *OctopusLink) CreateInferDeployInstance(ctx context.Context, option *opt
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
desc := option.ModelType + FORWARD_SLASH + option.ModelName + FORWARD_SLASH + BIV100
|
desc := option.ModelType + FORWARD_SLASH + option.ModelName + FORWARD_SLASH + strings.ToLower(BIV100)
|
||||||
param := &octopus.CreateNotebookParam{
|
param := &octopus.CreateNotebookParam{
|
||||||
Name: option.TaskName,
|
Name: option.TaskName,
|
||||||
ResourcePool: RESOURCE_POOL,
|
ResourcePool: RESOURCE_POOL,
|
||||||
|
|
Loading…
Reference in New Issue