@@ -72,11 +72,11 @@ type CloudBrainLoginResult struct { | |||
type TaskRole struct { | |||
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"` | |||
ShmMB int `json:"shmMB"` | |||
Command string `json:"command"` | |||
@@ -286,6 +286,18 @@ type GpuInfo struct { | |||
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 { | |||
Ip string `json:"ip"` | |||
TaskContainerId string `json:"taskContainerId"` | |||
@@ -13,6 +13,7 @@ type CreateCloudBrainForm struct { | |||
JobType string `form:"job_type" binding:"Required"` | |||
BenchmarkCategory string `form:"get_benchmark_category"` | |||
GpuType string `form:"gpu_type"` | |||
ResourceSpecId int `form:"resource_spec_id" binding:"Required"` | |||
} | |||
type CommitImageCloudBrainForm struct { | |||
@@ -23,12 +23,29 @@ const ( | |||
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 + | |||
setting.Attachment.Minio.Bucket + "/" + | |||
setting.Attachment.Minio.BasePath + | |||
models.AttachmentRelativePath(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{ | |||
JobName: jobName, | |||
RetryCount: 1, | |||
@@ -40,10 +57,10 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, | |||
TaskNumber: 1, | |||
MinSucceededTaskCount: 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, | |||
NeedIBDevice: false, | |||
IsMainRole: false, | |||
@@ -439,6 +439,7 @@ var ( | |||
JobType string | |||
GpuTypes string | |||
DebugServerHost string | |||
ResourceSpecs string | |||
//benchmark config | |||
IsBenchmarkEnabled bool | |||
@@ -1147,7 +1148,8 @@ func NewContext() { | |||
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("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") | |||
IsBenchmarkEnabled = sec.Key("ENABLED").MustBool(false) | |||
@@ -148,6 +148,11 @@ func CloudBrainNew(ctx *context.Context) { | |||
json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) | |||
} | |||
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["is_snn4imagenet_enabled"] = setting.IsSnn4imagenetEnabled | |||
ctx.HTML(200, tplCloudBrainNew) | |||
@@ -162,6 +167,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||
jobType := form.JobType | |||
gpuQueue := setting.JobType | |||
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath | |||
resourceSpecId := form.ResourceSpecId | |||
if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeSnn4imagenet) { | |||
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, "", "") | |||
} | |||
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 { | |||
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) | |||
return | |||
@@ -161,14 +161,15 @@ | |||
<div class="inline required field"> | |||
<label>镜像</label> | |||
<select class="ui search" id="cloudbrain_image" placeholder="选择镜像" style='width:385px;' name="image"> | |||
<input type="text" list="cloudbrain_image" placeholder="选择镜像" name="image"> | |||
<datalist class="ui search" id="cloudbrain_image" style='width:385px;' name="image"> | |||
{{range .images}} | |||
<option name="image" value="{{.Place}}">{{.PlaceView}}</option> | |||
{{end}} | |||
{{range .public_images}} | |||
<option name="image" value="{{.Place}}">{{.PlaceView}}</option> | |||
{{end}} | |||
</select> | |||
</datalist> | |||
</div> | |||
<div class="inline required field"> | |||
@@ -181,6 +182,15 @@ | |||
</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"> | |||
<label>数据集存放路径</label> | |||
<input name="dataset_path" id="cloudbrain_dataset_path" value="{{.dataset_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly"> | |||
</div> | |||
@@ -242,9 +252,9 @@ | |||
.dropdown(); | |||
$('#cloudbrain_image').select2({ | |||
placeholder: "选择镜像" | |||
}); | |||
// $('#cloudbrain_image').select2({ | |||
// placeholder: "选择镜像" | |||
// }); | |||
$(".ui.button.reset").click(function(e){ | |||
@@ -1,9 +1,9 @@ | |||
<template> | |||
<div> | |||
<h4 id="about-desc" class="ui header">简介 | |||
<a class="edit-icon" href="javascript:void(0)" @click="editClick"> | |||
<!-- <a class="edit-icon" href="javascript:void(0)" @click="editClick"> | |||
<i class="gray edit outline icon"></i> | |||
</a> | |||
</a> --> | |||
</h4> | |||
<edit-dialog-cmpt | |||
:vmContext="vmContext" | |||