|
|
|
@@ -21,19 +21,14 @@ import ( |
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/schedulers/option" |
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/service/collector" |
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" |
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" |
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
) |
|
|
|
|
|
|
|
type ShuguangAi struct { |
|
|
|
ctx context.Context |
|
|
|
svcCtx *svc.ServiceContext |
|
|
|
platform string |
|
|
|
participantId int64 |
|
|
|
} |
|
|
|
|
|
|
|
const ( |
|
|
|
RAM_SIZE_1G = 1024 // 1G |
|
|
|
WORKER_RAM_SIZE = 10240 // 10G |
|
|
|
WORKER_NUMBER = 1 |
|
|
|
WORKER_CPU_NUMBER = 5 |
|
|
|
@@ -45,12 +40,61 @@ const ( |
|
|
|
TASK_PYTORCH_PREFIX = "PytorchTask" |
|
|
|
TENSORFLOW = "Tensorflow" |
|
|
|
RESOURCE_GROUP = "wzhdtest" |
|
|
|
WorkPath = "/work/home/acgnnmfbwo/111111/py/" |
|
|
|
WorkPath = "/work/home/acgnnmfbwo/pcmv1/" |
|
|
|
TimeoutLimit = "10:00:00" |
|
|
|
PythonCodePath = "/work/home/acgnnmfbwo/111111/py/test.py" |
|
|
|
DATASETS_DIR = "/work/home/acgnnmfbwo/pcmv1/dataset" |
|
|
|
) |
|
|
|
|
|
|
|
var RESOURCESGMAP = map[string]ResourceSpecSG{ |
|
|
|
"WodTB2rJ8SobMgQ1nrtR245jxOrsovFi": { |
|
|
|
CPU: 1, |
|
|
|
GPU: 1, |
|
|
|
RAM: 2 * RAM_SIZE_1G, |
|
|
|
}, |
|
|
|
"6d41v1XV53MQPmQOJ5kNatIck9yl8nWZ": { |
|
|
|
CPU: 1, |
|
|
|
GPU: 2, |
|
|
|
RAM: 2 * RAM_SIZE_1G, |
|
|
|
}, |
|
|
|
"OBtVaaXAv9n9FbLR7pWAoa3yR13jXwNc": { |
|
|
|
CPU: 2, |
|
|
|
GPU: 1, |
|
|
|
RAM: 4 * RAM_SIZE_1G, |
|
|
|
}, |
|
|
|
"sBWfpkntUzsWYly11kdwEHZOYYIsFmve": { |
|
|
|
CPU: 5, |
|
|
|
GPU: 1, |
|
|
|
RAM: 10 * RAM_SIZE_1G, |
|
|
|
}, |
|
|
|
"jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2": { |
|
|
|
CPU: 5, |
|
|
|
GPU: 2, |
|
|
|
RAM: 10 * RAM_SIZE_1G, |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
var RESOURCESPECSAI = map[string]string{ |
|
|
|
"WodTB2rJ8SobMgQ1nrtR245jxOrsovFi": "CPU:1, DCU:1, RAM:2G", |
|
|
|
"6d41v1XV53MQPmQOJ5kNatIck9yl8nWZ": "CPU:1, DCU:2, RAM:2G", |
|
|
|
"OBtVaaXAv9n9FbLR7pWAoa3yR13jXwNc": "CPU:2, DCU:1, RAM:4G", |
|
|
|
"sBWfpkntUzsWYly11kdwEHZOYYIsFmve": "CPU:5, DCU:1, RAM:10G", |
|
|
|
"jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2": "CPU:5, DCU:2, RAM:10G", |
|
|
|
} |
|
|
|
|
|
|
|
type ResourceSpecSG struct { |
|
|
|
CPU int64 |
|
|
|
GPU int64 |
|
|
|
RAM int64 |
|
|
|
} |
|
|
|
|
|
|
|
type ShuguangAi struct { |
|
|
|
ctx context.Context |
|
|
|
svcCtx *svc.ServiceContext |
|
|
|
platform string |
|
|
|
participantId int64 |
|
|
|
} |
|
|
|
|
|
|
|
func NewShuguangAi(ctx context.Context, svcCtx *svc.ServiceContext, name string, id int64) *ShuguangAi { |
|
|
|
return &ShuguangAi{ctx: ctx, svcCtx: svcCtx, platform: name, participantId: id} |
|
|
|
} |
|
|
|
@@ -187,17 +231,19 @@ func (s *ShuguangAi) DeleteTask(taskId string) (interface{}, error) { |
|
|
|
} |
|
|
|
|
|
|
|
func (s *ShuguangAi) QuerySpecs() (interface{}, error) { |
|
|
|
// ShuguangAi查询资源规格 |
|
|
|
req := &hpcAC.GetResourceSpecReq{ |
|
|
|
AcceleratorType: DCU, |
|
|
|
ResourceGroup: RESOURCE_GROUP, |
|
|
|
} |
|
|
|
specs, err := s.svcCtx.ACRpc.GetResourceSpec(s.ctx, req) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
resp := &types.GetResourceSpecsResp{} |
|
|
|
|
|
|
|
for k, v := range RESOURCESPECSAI { |
|
|
|
var respec types.ResourceSpecSl |
|
|
|
respec.SpecId = k |
|
|
|
respec.SpecName = v |
|
|
|
respec.ParticipantId = s.participantId |
|
|
|
respec.ParticipantName = s.platform |
|
|
|
resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) |
|
|
|
} |
|
|
|
|
|
|
|
return specs, nil |
|
|
|
resp.Success = true |
|
|
|
return resp, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (s *ShuguangAi) GetResourceStats() (*collector.ResourceStats, error) { |
|
|
|
|