Browse Source

#3277

gcu:create notebook
tags/v1.22.12.2^2
chenyifan01 2 years ago
parent
commit
4616b9be8d
3 changed files with 29 additions and 4 deletions
  1. +10
    -2
      models/cloudbrain.go
  2. +1
    -0
      modules/grampus/grampus.go
  3. +18
    -2
      routers/repo/grampus.go

+ 10
- 2
models/cloudbrain.go View File

@@ -35,6 +35,7 @@ const (
const ( const (
NPUResource = "NPU" NPUResource = "NPU"
GPUResource = "CPU/GPU" GPUResource = "CPU/GPU"
GCUResource = "GCU"
AllResource = "all" AllResource = "all"


//notebook storage category //notebook storage category
@@ -134,6 +135,7 @@ const (
//ComputeResource //ComputeResource
GPU = "GPU" GPU = "GPU"
NPU = "NPU" NPU = "NPU"
GCU = "GCU"
) )


type Cloudbrain struct { type Cloudbrain struct {
@@ -205,7 +207,7 @@ type Cloudbrain struct {
BenchmarkTypeRankLink string `xorm:"-"` BenchmarkTypeRankLink string `xorm:"-"`
StartTime timeutil.TimeStamp StartTime timeutil.TimeStamp
EndTime timeutil.TimeStamp EndTime timeutil.TimeStamp
Cleared bool `xorm:"DEFAULT false"`
Cleared bool `xorm:"DEFAULT false"`
Spec *Specification `xorm:"-"` Spec *Specification `xorm:"-"`
} }


@@ -2589,8 +2591,14 @@ func GetDatasetInfo(uuidStr string, grampusType ...string) (map[string]DatasetIn
if len(grampusType) > 0 { if len(grampusType) > 0 {
if grampusType[0] == GPU { if grampusType[0] == GPU {
dataLocalPath = setting.Attachment.Minio.BasePath + path.Join(attach.UUID[0:1], attach.UUID[1:2]) + "/" + attach.UUID dataLocalPath = setting.Attachment.Minio.BasePath + path.Join(attach.UUID[0:1], attach.UUID[1:2]) + "/" + attach.UUID
} else {
} else if grampusType[0] == NPU {
dataLocalPath = setting.BasePath + path.Join(attach.UUID[0:1], attach.UUID[1:2]) + "/" + attach.UUID + "/" dataLocalPath = setting.BasePath + path.Join(attach.UUID[0:1], attach.UUID[1:2]) + "/" + attach.UUID + "/"
} else if grampusType[0] == GCU {
if attach.Type == TypeCloudBrainOne {
dataLocalPath = setting.BasePath + path.Join(attach.UUID[0:1], attach.UUID[1:2]) + "/" + attach.UUID + "/"
} else {
dataLocalPath = setting.Attachment.Minio.BasePath + path.Join(attach.UUID[0:1], attach.UUID[1:2]) + "/" + attach.UUID
}
} }


} else { } else {


+ 1
- 0
modules/grampus/grampus.go View File

@@ -18,6 +18,7 @@ const (


ProcessorTypeNPU = "npu.huawei.com/NPU" ProcessorTypeNPU = "npu.huawei.com/NPU"
ProcessorTypeGPU = "nvidia.com/gpu" ProcessorTypeGPU = "nvidia.com/gpu"
ProcessorTypeGCU = "enflame-tech.com/gcu"


GpuWorkDir = "/tmp/" GpuWorkDir = "/tmp/"
NpuWorkDir = "/cache/" NpuWorkDir = "/cache/"


+ 18
- 2
routers/repo/grampus.go View File

@@ -53,6 +53,8 @@ const (
//NPU //NPU
tplGrampusNotebookNPUNew base.TplName = "repo/grampus/notebook/npu/new" tplGrampusNotebookNPUNew base.TplName = "repo/grampus/notebook/npu/new"
tplGrampusTrainJobNPUNew base.TplName = "repo/grampus/trainjob/npu/new" tplGrampusTrainJobNPUNew base.TplName = "repo/grampus/trainjob/npu/new"
//GCU
tplGrampusNotebookGCUNew base.TplName = "repo/grampus/notebook/gcu/new"
) )


func GrampusNotebookNew(ctx *context.Context) { func GrampusNotebookNew(ctx *context.Context) {
@@ -61,6 +63,8 @@ func GrampusNotebookNew(ctx *context.Context) {
processType := grampus.ProcessorTypeGPU processType := grampus.ProcessorTypeGPU
if notebookType == 1 { if notebookType == 1 {
processType = grampus.ProcessorTypeNPU processType = grampus.ProcessorTypeNPU
} else if notebookType == 2 {
processType = grampus.ProcessorTypeGCU
} }
err := grampusNotebookNewDataPrepare(ctx, processType) err := grampusNotebookNewDataPrepare(ctx, processType)
if err != nil { if err != nil {
@@ -69,8 +73,10 @@ func GrampusNotebookNew(ctx *context.Context) {
} }
if processType == grampus.ProcessorTypeGPU { if processType == grampus.ProcessorTypeGPU {
ctx.HTML(http.StatusOK, tplGrampusNotebookGPUNew) ctx.HTML(http.StatusOK, tplGrampusNotebookGPUNew)
} else {
} else if processType == grampus.ProcessorTypeNPU {
ctx.HTML(http.StatusOK, tplGrampusNotebookNPUNew) ctx.HTML(http.StatusOK, tplGrampusNotebookNPUNew)
} else if processType == grampus.ProcessorTypeGCU {
ctx.HTML(http.StatusOK, tplGrampusNotebookGCUNew)
} }


} }
@@ -118,6 +124,12 @@ func GrampusNotebookCreate(ctx *context.Context, form auth.CreateGrampusNotebook
computeSource = models.NPUResource computeSource = models.NPUResource
computeSourceSimple = models.NPU computeSourceSimple = models.NPU
codeStoragePath = grampus.JobPath + jobName + modelarts.CodePath codeStoragePath = grampus.JobPath + jobName + modelarts.CodePath
} else if form.Type == 2 {
tpl = tplGrampusNotebookGCUNew
processType = grampus.ProcessorTypeGCU
computeSource = models.GCUResource
computeSourceSimple = models.GCU
codeStoragePath = grampus.JobPath + jobName + modelarts.CodePath
} }


lock := redis_lock.NewDistributeLock(redis_key.CloudbrainBindingJobNameKey(fmt.Sprint(repo.ID), string(models.JobTypeDebug), displayJobName)) lock := redis_lock.NewDistributeLock(redis_key.CloudbrainBindingJobNameKey(fmt.Sprint(repo.ID), string(models.JobTypeDebug), displayJobName))
@@ -295,7 +307,7 @@ func grampusNotebookNewDataPrepare(ctx *context.Context, processType string) err
ctx.Data["display_job_name"] = displayJobName ctx.Data["display_job_name"] = displayJobName


//get valid images //get valid images
if processType == grampus.ProcessorTypeNPU {
if processType == grampus.ProcessorTypeNPU || processType == grampus.ProcessorTypeGCU {
images, err := grampus.GetImages(processType, string(models.JobTypeDebug)) images, err := grampus.GetImages(processType, string(models.JobTypeDebug))
if err != nil { if err != nil {
log.Error("GetImages failed:", err.Error()) log.Error("GetImages failed:", err.Error())
@@ -311,6 +323,10 @@ func grampusNotebookNewDataPrepare(ctx *context.Context, processType string) err
computeResourceSimple = models.NPU computeResourceSimple = models.NPU
datasetType = models.TypeCloudBrainTwo datasetType = models.TypeCloudBrainTwo
computeResource = models.NPUResource computeResource = models.NPUResource
} else if processType == grampus.ProcessorTypeGCU {
computeResourceSimple = models.GCU
datasetType = models.TypeCloudBrainAll
computeResource = models.GCUResource
} }


prepareGrampusSpecs(ctx, computeResourceSimple, models.JobTypeDebug) prepareGrampusSpecs(ctx, computeResourceSimple, models.JobTypeDebug)


Loading…
Cancel
Save