| @@ -72,11 +72,11 @@ type CloudBrainLoginResult struct { | |||||
| type TaskRole struct { | type TaskRole struct { | ||||
| Name string `json:"name"` | Name string `json:"name"` | ||||
| TaskNumber int8 `json:"taskNumber"` | |||||
| MinSucceededTaskCount int8 `json:"minSucceededTaskCount"` | |||||
| MinFailedTaskCount int8 `json:"minFailedTaskCount"` | |||||
| CPUNumber int8 `json:"cpuNumber"` | |||||
| GPUNumber int8 `json:"gpuNumber"` | |||||
| TaskNumber int `json:"taskNumber"` | |||||
| MinSucceededTaskCount int `json:"minSucceededTaskCount"` | |||||
| MinFailedTaskCount int `json:"minFailedTaskCount"` | |||||
| CPUNumber int `json:"cpuNumber"` | |||||
| GPUNumber int `json:"gpuNumber"` | |||||
| MemoryMB int `json:"memoryMB"` | MemoryMB int `json:"memoryMB"` | ||||
| ShmMB int `json:"shmMB"` | ShmMB int `json:"shmMB"` | ||||
| Command string `json:"command"` | Command string `json:"command"` | ||||
| @@ -286,6 +286,18 @@ type GpuInfo struct { | |||||
| Queue string `json:"queue"` | Queue string `json:"queue"` | ||||
| } | } | ||||
| type ResourceSpecs struct { | |||||
| ResourceSpec []*ResourceSpec `json:"resorce_specs"` | |||||
| } | |||||
| type ResourceSpec struct { | |||||
| Id int `json:"id"` | |||||
| CpuNum int `json:"cpu"` | |||||
| GpuNum int `json:"gpu"` | |||||
| MemMiB int `json:"memMiB"` | |||||
| ShareMemMiB int `json:"shareMemMiB"` | |||||
| } | |||||
| type CommitImageParams struct { | type CommitImageParams struct { | ||||
| Ip string `json:"ip"` | Ip string `json:"ip"` | ||||
| TaskContainerId string `json:"taskContainerId"` | TaskContainerId string `json:"taskContainerId"` | ||||
| @@ -13,6 +13,7 @@ type CreateCloudBrainForm struct { | |||||
| JobType string `form:"job_type" binding:"Required"` | JobType string `form:"job_type" binding:"Required"` | ||||
| BenchmarkCategory string `form:"get_benchmark_category"` | BenchmarkCategory string `form:"get_benchmark_category"` | ||||
| GpuType string `form:"gpu_type"` | GpuType string `form:"gpu_type"` | ||||
| ResourceSpecId int `form:"resource_spec_id" binding:"Required"` | |||||
| } | } | ||||
| type CommitImageCloudBrainForm struct { | type CommitImageCloudBrainForm struct { | ||||
| @@ -23,12 +23,29 @@ const ( | |||||
| Success = "S000" | Success = "S000" | ||||
| ) | ) | ||||
| func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue string) error { | |||||
| var ( | |||||
| ResourceSpecs *models.ResourceSpecs | |||||
| ) | |||||
| func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue string, resourceSpecId int) error { | |||||
| dataActualPath := setting.Attachment.Minio.RealPath + | dataActualPath := setting.Attachment.Minio.RealPath + | ||||
| setting.Attachment.Minio.Bucket + "/" + | setting.Attachment.Minio.Bucket + "/" + | ||||
| setting.Attachment.Minio.BasePath + | setting.Attachment.Minio.BasePath + | ||||
| models.AttachmentRelativePath(uuid) + | models.AttachmentRelativePath(uuid) + | ||||
| uuid | uuid | ||||
| var resourceSpec *models.ResourceSpec | |||||
| for _, spec := range ResourceSpecs.ResourceSpec { | |||||
| if resourceSpecId == spec.Id { | |||||
| resourceSpec = spec | |||||
| } | |||||
| } | |||||
| if resourceSpec == nil { | |||||
| log.Error("no such resourceSpecId(%d)", resourceSpecId, ctx.Data["MsgID"]) | |||||
| return errors.New("no such resourceSpec") | |||||
| } | |||||
| jobResult, err := CreateJob(jobName, models.CreateJobParams{ | jobResult, err := CreateJob(jobName, models.CreateJobParams{ | ||||
| JobName: jobName, | JobName: jobName, | ||||
| RetryCount: 1, | RetryCount: 1, | ||||
| @@ -40,10 +57,10 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, | |||||
| TaskNumber: 1, | TaskNumber: 1, | ||||
| MinSucceededTaskCount: 1, | MinSucceededTaskCount: 1, | ||||
| MinFailedTaskCount: 1, | MinFailedTaskCount: 1, | ||||
| CPUNumber: 2, | |||||
| GPUNumber: 1, | |||||
| MemoryMB: 16384, | |||||
| ShmMB: 8192, | |||||
| CPUNumber: resourceSpec.CpuNum, | |||||
| GPUNumber: resourceSpec.GpuNum, | |||||
| MemoryMB: resourceSpec.MemMiB, | |||||
| ShmMB: resourceSpec.ShareMemMiB, | |||||
| Command: command, | Command: command, | ||||
| NeedIBDevice: false, | NeedIBDevice: false, | ||||
| IsMainRole: false, | IsMainRole: false, | ||||
| @@ -439,6 +439,7 @@ var ( | |||||
| JobType string | JobType string | ||||
| GpuTypes string | GpuTypes string | ||||
| DebugServerHost string | DebugServerHost string | ||||
| ResourceSpecs string | |||||
| //benchmark config | //benchmark config | ||||
| IsBenchmarkEnabled bool | IsBenchmarkEnabled bool | ||||
| @@ -1147,7 +1148,8 @@ func NewContext() { | |||||
| JobPath = sec.Key("JOB_PATH").MustString("/datasets/minio/data/opendata/jobs/") | JobPath = sec.Key("JOB_PATH").MustString("/datasets/minio/data/opendata/jobs/") | ||||
| DebugServerHost = sec.Key("DEBUG_SERVER_HOST").MustString("http://192.168.202.73") | DebugServerHost = sec.Key("DEBUG_SERVER_HOST").MustString("http://192.168.202.73") | ||||
| JobType = sec.Key("GPU_TYPE_DEFAULT").MustString("openidebug") | JobType = sec.Key("GPU_TYPE_DEFAULT").MustString("openidebug") | ||||
| GpuTypes = sec.Key("GPU_TYPES").MustString("openidebug,openidgx") | |||||
| GpuTypes = sec.Key("GPU_TYPES").MustString("") | |||||
| ResourceSpecs = sec.Key("RESOURCE_SPECS").MustString("") | |||||
| sec = Cfg.Section("benchmark") | sec = Cfg.Section("benchmark") | ||||
| IsBenchmarkEnabled = sec.Key("ENABLED").MustBool(false) | IsBenchmarkEnabled = sec.Key("ENABLED").MustBool(false) | ||||
| @@ -148,6 +148,11 @@ func CloudBrainNew(ctx *context.Context) { | |||||
| json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) | json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) | ||||
| } | } | ||||
| ctx.Data["gpu_types"] = gpuInfos.GpuInfo | ctx.Data["gpu_types"] = gpuInfos.GpuInfo | ||||
| if cloudbrain.ResourceSpecs == nil { | |||||
| json.Unmarshal([]byte(setting.ResourceSpecs), &cloudbrain.ResourceSpecs) | |||||
| } | |||||
| ctx.Data["resource_specs"] = cloudbrain.ResourceSpecs.ResourceSpec | |||||
| ctx.Data["snn4imagenet_path"] = cloudbrain.Snn4imagenetMountPath | ctx.Data["snn4imagenet_path"] = cloudbrain.Snn4imagenetMountPath | ||||
| ctx.Data["is_snn4imagenet_enabled"] = setting.IsSnn4imagenetEnabled | ctx.Data["is_snn4imagenet_enabled"] = setting.IsSnn4imagenetEnabled | ||||
| ctx.HTML(200, tplCloudBrainNew) | ctx.HTML(200, tplCloudBrainNew) | ||||
| @@ -162,6 +167,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||||
| jobType := form.JobType | jobType := form.JobType | ||||
| gpuQueue := setting.JobType | gpuQueue := setting.JobType | ||||
| codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath | codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath | ||||
| resourceSpecId := form.ResourceSpecId | |||||
| if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeSnn4imagenet) { | if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeSnn4imagenet) { | ||||
| log.Error("jobtype error:", jobType, ctx.Data["msgID"]) | log.Error("jobtype error:", jobType, ctx.Data["msgID"]) | ||||
| @@ -208,7 +214,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||||
| downloadRateCode(repo, jobName, setting.Snn4imagenetCode, snn4imagenetPath, "", "") | downloadRateCode(repo, jobName, setting.Snn4imagenetCode, snn4imagenetPath, "", "") | ||||
| } | } | ||||
| err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue) | |||||
| err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue, resourceSpecId) | |||||
| if err != nil { | if err != nil { | ||||
| ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) | ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) | ||||
| return | return | ||||
| @@ -181,6 +181,15 @@ | |||||
| </select> | </select> | ||||
| </div> | </div> | ||||
| <div class="inline required field"> | |||||
| <label>资源规格</label> | |||||
| <select id="cloudbrain_resource_spec" class="ui search dropdown" placeholder="选择资源规格" style='width:385px' name="resource_spec_id"> | |||||
| {{range .resource_specs}} | |||||
| <option name="resource_spec_id" value="{{.Id}}">GPU数:{{.GpuNum}},CPU数:{{.CpuNum}},内存(MB):{{.MemMiB}},共享内存(MB):{{.ShareMemMiB}}</option> | |||||
| {{end}} | |||||
| </select> | |||||
| </div> | |||||
| <div class="inline required field"> | <div class="inline required field"> | ||||
| <label>数据集存放路径</label> | <label>数据集存放路径</label> | ||||
| <input name="dataset_path" id="cloudbrain_dataset_path" value="{{.dataset_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly"> | <input name="dataset_path" id="cloudbrain_dataset_path" value="{{.dataset_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly"> | ||||
| @@ -12,6 +12,15 @@ | |||||
| float: left; | float: left; | ||||
| margin: .25em; | margin: .25em; | ||||
| } | } | ||||
| .edit-link{ | |||||
| vertical-align: top; | |||||
| display: inline-block; | |||||
| overflow: hidden; | |||||
| word-break: keep-all; | |||||
| white-space: nowrap; | |||||
| text-overflow: ellipsis; | |||||
| width: 16.5em; | |||||
| } | |||||
| #contributorInfo > a.circular{ | #contributorInfo > a.circular{ | ||||
| height: 2.0em; | height: 2.0em; | ||||
| padding: 0; | padding: 0; | ||||
| @@ -218,7 +227,7 @@ | |||||
| {{if .Repository.Website}} | {{if .Repository.Website}} | ||||
| <p class="ui"> | <p class="ui"> | ||||
| <i class="gray linkify icon"></i> | <i class="gray linkify icon"></i> | ||||
| <a class="link" target="_blank" href="{{.Repository.Website}}">{{.Repository.Website}}</a> | |||||
| <a class="link edit-link" target="_blank" title="{{.Repository.Website}}" href="{{.Repository.Website}}">{{.Repository.Website}}</a> | |||||
| </p> | </p> | ||||
| {{end}} | {{end}} | ||||