diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 5c0a5f007..00d4b00e6 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -276,6 +276,16 @@ type Category struct { Value string `json:"value"` } +type GpuTypes struct { + GpuType []*GpuType `json:"gpu_type"` +} + +type GpuType struct { + Id int `json:"id"` + Value string `json:"value"` + Queue string `json:"queue"` +} + type CommitImageParams struct { Ip string `json:"ip"` TaskContainerId string `json:"taskContainerId"` diff --git a/modules/auth/cloudbrain.go b/modules/auth/cloudbrain.go index b4f0c8f7c..335bc1666 100755 --- a/modules/auth/cloudbrain.go +++ b/modules/auth/cloudbrain.go @@ -12,6 +12,7 @@ type CreateCloudBrainForm struct { Attachment string `form:"attachment" binding:"Required"` JobType string `form:"job_type" binding:"Required"` BenchmarkCategory string `form:"get_benchmark_category"` + GpuType string `form:"gpu_type"` } type CommitImageCloudBrainForm struct { diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index 1e52bd096..2f22f9770 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -23,7 +23,7 @@ const ( Success = "S000" ) -func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType string) error { +func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuType string) error { dataActualPath := setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.BasePath + @@ -32,7 +32,7 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, jobResult, err := CreateJob(jobName, models.CreateJobParams{ JobName: jobName, RetryCount: 1, - GpuType: setting.JobType, + GpuType: gpuType, Image: image, TaskRoles: []models.TaskRole{ { diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 9b69d238a..7785028f8 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -437,6 +437,7 @@ var ( RestServerHost string JobPath string JobType string + GpuTypes string DebugServerHost string //benchmark config @@ -1145,7 +1146,8 @@ func NewContext() { RestServerHost = sec.Key("REST_SERVER_HOST").MustString("http://192.168.202.73") JobPath = sec.Key("JOB_PATH").MustString("/datasets/minio/data/opendata/jobs/") DebugServerHost = sec.Key("DEBUG_SERVER_HOST").MustString("http://192.168.202.73") - JobType = sec.Key("JOB_TYPE").MustString("debug_openi") + JobType = sec.Key("GPU_TYPE_DEFAULT").MustString("openidebug") + GpuTypes = sec.Key("GPU_TYPES").MustString("openidebug,openidgx") sec = Cfg.Section("benchmark") IsBenchmarkEnabled = sec.Key("ENABLED").MustBool(false) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 5ef8f2979..0c1b34836 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -134,6 +134,9 @@ func CloudBrainNew(ctx *context.Context) { var categories *models.Categories json.Unmarshal([]byte(setting.BenchmarkCategory), &categories) ctx.Data["benchmark_categories"] = categories.Category + var gpuTypes *models.GpuTypes + json.Unmarshal([]byte(setting.GpuTypes), &gpuTypes) + ctx.Data["gpu_types"] = gpuTypes.GpuType ctx.Data["snn4imagenet_path"] = cloudbrain.Snn4imagenetMountPath ctx.Data["is_snn4imagenet_enabled"] = setting.IsSnn4imagenetEnabled ctx.HTML(200, tplCloudBrainNew) @@ -146,6 +149,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { command := form.Command uuid := form.Attachment jobType := form.JobType + gpuType := setting.JobType codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeSnn4imagenet) { @@ -165,6 +169,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath if setting.IsBenchmarkEnabled && jobType == string(models.JobTypeBenchmark) { + gpuType = form.GpuType downloadRateCode(repo, jobName, setting.BenchmarkCode, benchmarkPath, form.BenchmarkCategory) } @@ -173,7 +178,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { downloadRateCode(repo, jobName, setting.Snn4imagenetCode, snn4imagenetPath, "") } - err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType) + err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuType) if err != nil { ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) return diff --git a/templates/repo/cloudbrain/new.tmpl b/templates/repo/cloudbrain/new.tmpl index a2b307efb..6c07e427f 100755 --- a/templates/repo/cloudbrain/new.tmpl +++ b/templates/repo/cloudbrain/new.tmpl @@ -139,6 +139,15 @@ +
+ + +
+