From 6cb1889208fef24867880986c8158a4e41d7093e Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Tue, 28 Jun 2022 20:10:30 +0800 Subject: [PATCH] debug gpu --- models/cloudbrain.go | 17 ++++++++++------- modules/cloudbrain/cloudbrain.go | 2 +- routers/repo/cloudbrain.go | 12 ++++++------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index c0b5e5597..fe9b60276 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -1951,12 +1951,12 @@ type DatasetInfo struct { Name string } -func GetDatasetInfo(uuidStr string) (map[string]DatasetInfo, string, error) { - var datasetNames string +func GetDatasetInfo(uuidStr string) (map[string]DatasetInfo, string, string, error) { + var datasetNames, fileNames string uuids := strings.Split(uuidStr, ";") if len(uuids) > setting.MaxDatasetNum { log.Error("the dataset count(%d) exceed the limit", len(uuids)) - return nil, datasetNames, errors.New("the dataset count exceed the limit") + return nil, datasetNames, fileNames, errors.New("the dataset count exceed the limit") } datasetInfos := make(map[string]DatasetInfo) @@ -1964,13 +1964,13 @@ func GetDatasetInfo(uuidStr string) (map[string]DatasetInfo, string, error) { attach, err := GetAttachmentByUUID(uuid) if err != nil { log.Error("GetAttachmentByUUID failed: %v", err) - return nil, datasetNames, err + return nil, datasetNames, fileNames, err } for _, datasetInfo := range datasetInfos { if attach.Name == datasetInfo.Name { log.Error("the dataset name is same: %v", attach.Name) - return nil, datasetNames, errors.New("the dataset name is same") + return nil, datasetNames, fileNames, errors.New("the dataset name is same") } } @@ -1980,16 +1980,19 @@ func GetDatasetInfo(uuidStr string) (map[string]DatasetInfo, string, error) { AttachmentRelativePath(uuid) + uuid + fileName := strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(attach.Name, ".zip"), ".tar.gz"), ".tgz") datasetInfos[uuid] = DatasetInfo{ DataLocalPath: dataLocalPath, - Name: strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(attach.Name, ".zip"), ".tar.gz"), ".tgz"), + Name: fileName, } if i == 0 { datasetNames = attach.Name + fileNames = fileName } else { datasetNames += ";" + attach.Name + fileNames += "|" + fileName } } - return datasetInfos, datasetNames, nil + return datasetInfos, datasetNames, fileNames, nil } diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index 430304dd5..b1cc058cb 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -406,7 +406,7 @@ func RestartTask(ctx *context.Context, task *models.Cloudbrain, newID *string) e return errors.New("no such resourceSpec") } - datasetInfos, _, err := models.GetDatasetInfo(task.Uuid) + datasetInfos, _, _, err := models.GetDatasetInfo(task.Uuid) if err != nil { log.Error("GetDatasetInfo failed:%v", err, ctx.Data["MsgID"]) return err diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index c08e864c6..98e1e6577 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -261,7 +261,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { } } - datasetInfos, datasetNames, err := models.GetDatasetInfo(uuids) + datasetInfos, datasetNames, fileNames, err := models.GetDatasetInfo(uuids) if err != nil { log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"]) cloudBrainNewDataPrepare(ctx) @@ -272,7 +272,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { command := cloudbrain.Command if jobType == string(models.JobTypeTrain) { tpl = tplCloudBrainTrainJobNew - commandTrain, err := getTrainJobCommand(form, datasetNames) + commandTrain, err := getTrainJobCommand(form, fileNames) if err != nil { log.Error("getTrainJobCommand failed: %v", err) ctx.RenderWithErr(err.Error(), tpl, &form) @@ -2036,7 +2036,7 @@ func BenchMarkAlgorithmCreate(ctx *context.Context, form auth.CreateCloudBrainFo } uuid := childInfo.Attachment - datasetInfos, datasetNames, err := models.GetDatasetInfo(uuid) + datasetInfos, datasetNames, _, err := models.GetDatasetInfo(uuid) if err != nil { log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"]) cloudBrainNewDataPrepare(ctx) @@ -2164,7 +2164,7 @@ func ModelBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainForm) command = fmt.Sprintf(cloudbrain.BrainScoreCommand, getBrainRegion(benchmarkChildTypeID), displayJobName, trimSpaceNewlineInString(form.Description)) } - datasetInfos, datasetNames, err := models.GetDatasetInfo(uuid) + datasetInfos, datasetNames, _, err := models.GetDatasetInfo(uuid) if err != nil { log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"]) cloudBrainNewDataPrepare(ctx) @@ -2246,7 +2246,7 @@ func CloudBrainTrainJobNew(ctx *context.Context) { ctx.HTML(http.StatusOK, tplCloudBrainTrainJobNew) } -func getTrainJobCommand(form auth.CreateCloudBrainForm, datasetNames string) (string, error) { +func getTrainJobCommand(form auth.CreateCloudBrainForm, fileNames string) (string, error) { var command string bootFile := strings.TrimSpace(form.BootFile) params := form.Params @@ -2270,7 +2270,7 @@ func getTrainJobCommand(form auth.CreateCloudBrainForm, datasetNames string) (st } } - param += " --dataset_list=" + datasetNames + param += " --dataset_list=" + fileNames command += "python /code/" + bootFile + param + " > " + cloudbrain.ModelMountPath + "/" + form.DisplayJobName + "-" + cloudbrain.LogFile