Browse Source

add gpy_type select

pull/74/head
lewis 4 years ago
parent
commit
12aa528b9e
6 changed files with 31 additions and 4 deletions
  1. +10
    -0
      models/cloudbrain.go
  2. +1
    -0
      modules/auth/cloudbrain.go
  3. +2
    -2
      modules/cloudbrain/cloudbrain.go
  4. +3
    -1
      modules/setting/setting.go
  5. +6
    -1
      routers/repo/cloudbrain.go
  6. +9
    -0
      templates/repo/cloudbrain/new.tmpl

+ 10
- 0
models/cloudbrain.go View File

@@ -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"`


+ 1
- 0
modules/auth/cloudbrain.go View File

@@ -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 {


+ 2
- 2
modules/cloudbrain/cloudbrain.go View File

@@ -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{
{


+ 3
- 1
modules/setting/setting.go View File

@@ -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)


+ 6
- 1
routers/repo/cloudbrain.go View File

@@ -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


+ 9
- 0
templates/repo/cloudbrain/new.tmpl View File

@@ -139,6 +139,15 @@
</div>
<input id="store_category" type="hidden" name="get_benchmark_category">

<div class="inline required field cloudbrain_benchmark">
<label>GPU类型</label>
<select id="cloudbrain_gpu_type" class="ui search dropdown" placeholder="选择GPU类型" style='width:385px' name="gpu_type">
{{range .gpu_types}}
<option value="{{.Queue}}">{{.Value}}</option>
{{end}}
</select>
</div>

<div class="inline required field">
<label>镜像</label>
<select class="ui search dropdown" id="cloudbrain_image" placeholder="选择镜像" style='width:385px' name="image">


Loading…
Cancel
Save