Browse Source

智算gpu调试挂载/model作为输出目录

tags/v1.22.12.1^2
ychao_1983 3 years ago
parent
commit
b2c9147fa4
3 changed files with 29 additions and 4 deletions
  1. +13
    -2
      modules/grampus/grampus.go
  2. +6
    -1
      routers/repo/cloudbrain.go
  3. +10
    -1
      routers/repo/grampus.go

+ 13
- 2
modules/grampus/grampus.go View File

@@ -106,6 +106,7 @@ type GenerateNotebookJobReq struct {
PreTrainModelUrl string
Spec *models.Specification
CodeName string
ModelPath string //参考启智GPU调试, 挂载/model目录用户的模型可以输出到这个目录
}

func getEndPoint() string {
@@ -184,16 +185,26 @@ func GenerateNotebookJob(ctx *context.Context, req *GenerateNotebookJobReq) (job
EndPoint: setting.Attachment.Minio.Endpoint,
ObjectKey: req.PreTrainModelPath,
ReadOnly: true,
ContainerPath: "/model",
ContainerPath: cloudbrain.PretrainModelMountPath,
})
}

datasetGrampus = append(datasetGrampus, models.GrampusDataset{
Name: "modelOutput",
Bucket: setting.Bucket,
EndPoint: getEndPoint(),
ReadOnly: false,
ObjectKey: req.ModelPath,
ContainerPath: cloudbrain.ModelMountPath,
})

codeGrampus = models.GrampusDataset{
Name: req.CodeName,
Bucket: setting.Attachment.Minio.Bucket,
EndPoint: setting.Attachment.Minio.Endpoint,
ObjectKey: req.CodeStoragePath + cloudbrain.DefaultBranchName + ".zip",
ReadOnly: false,
ContainerPath: "/code",
ContainerPath: cloudbrain.CodeMountPath,
}
req.Command = fmt.Sprintf(CommandGpuDebug, cpCommand)
log.Info("debug command:" + req.Command)


+ 6
- 1
routers/repo/cloudbrain.go View File

@@ -418,8 +418,13 @@ func loadCodeAndMakeModelPath(repo *models.Repository, codePath string, branchNa
return "cloudbrain.load_code_failed"
}

return initModelPath(jobName, resultPath)

}

func initModelPath(jobName string, resultPath string) string {
modelPath := setting.JobPath + jobName + resultPath + "/"
err = mkModelPath(modelPath)
err := mkModelPath(modelPath)
if err != nil {
return "cloudbrain.load_code_failed"
}


+ 10
- 1
routers/repo/grampus.go View File

@@ -104,9 +104,9 @@ func GrampusNotebookCreate(ctx *context.Context, form auth.CreateGrampusNotebook
repo := ctx.Repo.Repository
branchName := form.BranchName
image := strings.TrimSpace(form.Image)
codeLocalPath := setting.JobPath + jobName + cloudbrain.CodeMountPath + "/"

codeStoragePath := setting.CBCodePathPrefix + jobName + cloudbrain.CodeMountPath + "/"
modelStoragePath := setting.CBCodePathPrefix + jobName + cloudbrain.ModelMountPath + "/"

tpl := tplGrampusNotebookGPUNew
processType := grampus.ProcessorTypeGPU
@@ -203,6 +203,7 @@ func GrampusNotebookCreate(ctx *context.Context, form auth.CreateGrampusNotebook
}

//prepare code and out path
codeLocalPath := setting.JobPath + jobName + cloudbrain.CodeMountPath + "/"
_, err = ioutil.ReadDir(codeLocalPath)
if err == nil {
os.RemoveAll(codeLocalPath)
@@ -222,6 +223,13 @@ func GrampusNotebookCreate(ctx *context.Context, form auth.CreateGrampusNotebook
ctx.RenderWithErr(ctx.Tr("cloudbrain.load_code_failed"), tpl, &form)
return
}
errStr := initModelPath(jobName, cloudbrain.ModelMountPath)
if errStr != "" {
grampusNotebookNewDataPrepare(ctx, processType)
ctx.RenderWithErr(ctx.Tr(errStr), tpl, &form)
return
}

} else {

if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil {
@@ -250,6 +258,7 @@ func GrampusNotebookCreate(ctx *context.Context, form auth.CreateGrampusNotebook
Spec: spec,
CodeStoragePath: codeStoragePath,
CodeName: strings.ToLower(repo.Name),
ModelPath: modelStoragePath,
}

if form.ModelName != "" { //使用预训练模型训练


Loading…
Cancel
Save