Browse Source

optimization

pull/95/head
lewis 1 month ago
parent
commit
404deb89cd
3 changed files with 23 additions and 11 deletions
  1. +3
    -3
      models/cloudbrain.go
  2. +2
    -2
      modules/cloudbrain/cloudbrain.go
  3. +18
    -6
      routers/repo/cloudbrain.go

+ 3
- 3
models/cloudbrain.go View File

@@ -277,11 +277,11 @@ type Category struct {
Value string `json:"value"`
}

type GpuTypes struct {
GpuType []*GpuType `json:"gpu_type"`
type GpuInfos struct {
GpuInfo []*GpuInfo `json:"gpu_type"`
}

type GpuType struct {
type GpuInfo struct {
Id int `json:"id"`
Value string `json:"value"`
Queue string `json:"queue"`


+ 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, gpuType string) error {
func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue 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: gpuType,
GpuType: gpuQueue,
Image: image,
TaskRoles: []models.TaskRole{
{


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

@@ -25,6 +25,10 @@ const (
tplCloudBrainShow base.TplName = "repo/cloudbrain/show"
)

var (
gpuInfos *models.GpuInfos
)

// MustEnableDataset check if repository enable internal cb
func MustEnableCloudbrain(ctx *context.Context) {
if !ctx.Repo.CanRead(models.UnitTypeCloudBrain) {
@@ -134,9 +138,11 @@ 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

if gpuInfos == nil {
json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos)
}
ctx.Data["gpu_types"] = gpuInfos.GpuInfo
ctx.Data["snn4imagenet_path"] = cloudbrain.Snn4imagenetMountPath
ctx.Data["is_snn4imagenet_enabled"] = setting.IsSnn4imagenetEnabled
ctx.HTML(200, tplCloudBrainNew)
@@ -149,7 +155,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {
command := form.Command
uuid := form.Attachment
jobType := form.JobType
gpuType := setting.JobType
gpuQueue := setting.JobType
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath

if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeSnn4imagenet) {
@@ -169,7 +175,13 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {

benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath
if setting.IsBenchmarkEnabled && jobType == string(models.JobTypeBenchmark) {
gpuType = form.GpuType
gpuQueue = form.GpuType
var gpuType string
for _, gpuInfo := range gpuInfos.GpuInfo {
if gpuInfo.Queue == gpuQueue {
gpuType = gpuInfo.Value
}
}
downloadRateCode(repo, jobName, setting.BenchmarkCode, benchmarkPath, form.BenchmarkCategory, gpuType)
}

@@ -178,7 +190,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, gpuType)
err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue)
if err != nil {
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form)
return


Loading…
Cancel
Save