|
|
@@ -743,128 +743,13 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo |
|
|
|
ctx.NotFound(ctx.Req.URL.RequestURI(), nil) |
|
|
|
return |
|
|
|
} |
|
|
|
hasSpec := false |
|
|
|
if task.JobType == string(models.JobTypeTrain) { |
|
|
|
if cloudbrain.TrainResourceSpecs == nil { |
|
|
|
json.Unmarshal([]byte(setting.TrainResourceSpecs), &cloudbrain.TrainResourceSpecs) |
|
|
|
} |
|
|
|
|
|
|
|
for _, tmp := range cloudbrain.TrainResourceSpecs.ResourceSpec { |
|
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
|
hasSpec = true |
|
|
|
ctx.Data["GpuNum"] = tmp.GpuNum |
|
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if task.JobType == string(models.JobTypeInference) { |
|
|
|
if cloudbrain.InferenceResourceSpecs == nil { |
|
|
|
json.Unmarshal([]byte(setting.InferenceResourceSpecs), &cloudbrain.InferenceResourceSpecs) |
|
|
|
} |
|
|
|
for _, tmp := range cloudbrain.InferenceResourceSpecs.ResourceSpec { |
|
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
|
hasSpec = true |
|
|
|
ctx.Data["GpuNum"] = tmp.GpuNum |
|
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if cloudbrain.ResourceSpecs == nil { |
|
|
|
json.Unmarshal([]byte(setting.ResourceSpecs), &cloudbrain.ResourceSpecs) |
|
|
|
} |
|
|
|
for _, tmp := range cloudbrain.ResourceSpecs.ResourceSpec { |
|
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
|
hasSpec = true |
|
|
|
ctx.Data["GpuNum"] = tmp.GpuNum |
|
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if !hasSpec && cloudbrain.SpecialPools != nil { |
|
|
|
|
|
|
|
for _, specialPool := range cloudbrain.SpecialPools.Pools { |
|
|
|
|
|
|
|
if specialPool.ResourceSpec != nil { |
|
|
|
|
|
|
|
for _, spec := range specialPool.ResourceSpec { |
|
|
|
if task.ResourceSpecId == spec.Id { |
|
|
|
ctx.Data["GpuNum"] = spec.GpuNum |
|
|
|
ctx.Data["CpuNum"] = spec.CpuNum |
|
|
|
ctx.Data["MemMiB"] = spec.MemMiB |
|
|
|
ctx.Data["ShareMemMiB"] = spec.ShareMemMiB |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
prepareSpec4Show(ctx, task) |
|
|
|
if ctx.Written() { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if result != nil { |
|
|
|
jobRes, _ := models.ConvertToJobResultPayload(result.Payload) |
|
|
|
jobRes.Resource.Memory = strings.ReplaceAll(jobRes.Resource.Memory, "Mi", "MB") |
|
|
|
spec := "GPU数:" + strconv.Itoa(jobRes.Resource.NvidiaComGpu) + ",CPU数:" + strconv.Itoa(jobRes.Resource.CPU) + ",内存(MB):" + jobRes.Resource.Memory |
|
|
|
ctx.Data["resource_spec"] = spec |
|
|
|
if task.JobType == string(models.JobTypeTrain) { |
|
|
|
if trainGpuInfos == nil { |
|
|
|
json.Unmarshal([]byte(setting.TrainGpuTypes), &trainGpuInfos) |
|
|
|
} |
|
|
|
for _, resourceType := range trainGpuInfos.GpuInfo { |
|
|
|
if resourceType.Queue == jobRes.Config.GpuType { |
|
|
|
ctx.Data["resource_type"] = resourceType.Value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if task.JobType == string(models.JobTypeInference) { |
|
|
|
if inferenceGpuInfos == nil { |
|
|
|
json.Unmarshal([]byte(setting.InferenceGpuTypes), &inferenceGpuInfos) |
|
|
|
} |
|
|
|
for _, resourceType := range inferenceGpuInfos.GpuInfo { |
|
|
|
if resourceType.Queue == jobRes.Config.GpuType { |
|
|
|
ctx.Data["resource_type"] = resourceType.Value |
|
|
|
} |
|
|
|
} |
|
|
|
} else if cloudbrain.IsBenchmarkJob(task.JobType) { |
|
|
|
if benchmarkGpuInfos == nil { |
|
|
|
json.Unmarshal([]byte(setting.BenchmarkGpuTypes), &benchmarkGpuInfos) |
|
|
|
} |
|
|
|
|
|
|
|
for _, resourceType := range benchmarkGpuInfos.GpuInfo { |
|
|
|
if resourceType.Queue == jobRes.Config.GpuType { |
|
|
|
ctx.Data["resource_type"] = resourceType.Value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
if gpuInfos == nil { |
|
|
|
json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) |
|
|
|
} |
|
|
|
for _, resourceType := range gpuInfos.GpuInfo { |
|
|
|
if resourceType.Queue == jobRes.Config.GpuType { |
|
|
|
ctx.Data["resource_type"] = resourceType.Value |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if cloudbrain.SpecialPools != nil { |
|
|
|
for _, specialPool := range cloudbrain.SpecialPools.Pools { |
|
|
|
for _, resourceType := range specialPool.Pool { |
|
|
|
if resourceType.Queue == jobRes.Config.GpuType { |
|
|
|
ctx.Data["resource_type"] = resourceType.Value |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
taskRoles := jobRes.TaskRoles |
|
|
|
taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) |
|
|
|
ctx.Data["taskRes"] = taskRes |
|
|
@@ -988,6 +873,86 @@ func CloudBrainDebug(ctx *context.Context) { |
|
|
|
ctx.Redirect(debugUrl) |
|
|
|
} |
|
|
|
|
|
|
|
func prepareSpec4Show(ctx *context.Context, task *models.Cloudbrain) { |
|
|
|
s, err := resource.GetCloudbrainSpec(task.ID) |
|
|
|
if err != nil { |
|
|
|
log.Info("error:" + err.Error()) |
|
|
|
ctx.NotFound(ctx.Req.URL.RequestURI(), nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Data["Spec"] = s |
|
|
|
} |
|
|
|
|
|
|
|
func oldPrepareSpec4Show(ctx *context.Context, task *models.Cloudbrain) { |
|
|
|
hasSpec := false |
|
|
|
if task.JobType == string(models.JobTypeTrain) { |
|
|
|
if cloudbrain.TrainResourceSpecs == nil { |
|
|
|
json.Unmarshal([]byte(setting.TrainResourceSpecs), &cloudbrain.TrainResourceSpecs) |
|
|
|
} |
|
|
|
|
|
|
|
for _, tmp := range cloudbrain.TrainResourceSpecs.ResourceSpec { |
|
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
|
hasSpec = true |
|
|
|
ctx.Data["GpuNum"] = tmp.GpuNum |
|
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if task.JobType == string(models.JobTypeInference) { |
|
|
|
if cloudbrain.InferenceResourceSpecs == nil { |
|
|
|
json.Unmarshal([]byte(setting.InferenceResourceSpecs), &cloudbrain.InferenceResourceSpecs) |
|
|
|
} |
|
|
|
for _, tmp := range cloudbrain.InferenceResourceSpecs.ResourceSpec { |
|
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
|
hasSpec = true |
|
|
|
ctx.Data["GpuNum"] = tmp.GpuNum |
|
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if cloudbrain.ResourceSpecs == nil { |
|
|
|
json.Unmarshal([]byte(setting.ResourceSpecs), &cloudbrain.ResourceSpecs) |
|
|
|
} |
|
|
|
for _, tmp := range cloudbrain.ResourceSpecs.ResourceSpec { |
|
|
|
if tmp.Id == task.ResourceSpecId { |
|
|
|
hasSpec = true |
|
|
|
ctx.Data["GpuNum"] = tmp.GpuNum |
|
|
|
ctx.Data["CpuNum"] = tmp.CpuNum |
|
|
|
ctx.Data["MemMiB"] = tmp.MemMiB |
|
|
|
ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB |
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if !hasSpec && cloudbrain.SpecialPools != nil { |
|
|
|
|
|
|
|
for _, specialPool := range cloudbrain.SpecialPools.Pools { |
|
|
|
|
|
|
|
if specialPool.ResourceSpec != nil { |
|
|
|
|
|
|
|
for _, spec := range specialPool.ResourceSpec { |
|
|
|
if task.ResourceSpecId == spec.Id { |
|
|
|
ctx.Data["GpuNum"] = spec.GpuNum |
|
|
|
ctx.Data["CpuNum"] = spec.CpuNum |
|
|
|
ctx.Data["MemMiB"] = spec.MemMiB |
|
|
|
ctx.Data["ShareMemMiB"] = spec.ShareMemMiB |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func CloudBrainCommitImageShow(ctx *context.Context) { |
|
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
|
ctx.Data["Type"] = ctx.Cloudbrain.Type |
|
|
|