You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cloudbrain.go 16 kB

5 years ago
5 years ago
5 years ago
3 years ago
4 years ago
4 years ago
3 years ago
4 years ago
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 years ago
5 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. package cloudbrain
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "strconv"
  6. "code.gitea.io/gitea/modules/timeutil"
  7. "code.gitea.io/gitea/modules/storage"
  8. "code.gitea.io/gitea/models"
  9. "code.gitea.io/gitea/modules/context"
  10. "code.gitea.io/gitea/modules/log"
  11. "code.gitea.io/gitea/modules/notification"
  12. "code.gitea.io/gitea/modules/setting"
  13. )
  14. const (
  15. Command = `pip3 install jupyterlab==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple;service ssh stop;jupyter lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir="/code" --port=80 --LabApp.token="" --LabApp.allow_origin="self https://cloudbrain.pcl.ac.cn"`
  16. //CommandBenchmark = `echo "start benchmark";python /code/test.py;echo "end benchmark"`
  17. CommandBenchmark = `echo "start benchmark";cd /benchmark && bash run_bk.sh;echo "end benchmark"`
  18. CodeMountPath = "/code"
  19. DataSetMountPath = "/dataset"
  20. ModelMountPath = "/model"
  21. LogFile = "log.txt"
  22. BenchMarkMountPath = "/benchmark"
  23. BenchMarkResourceID = 1
  24. Snn4imagenetMountPath = "/snn4imagenet"
  25. BrainScoreMountPath = "/brainscore"
  26. TaskInfoName = "/taskInfo"
  27. Snn4imagenetCommand = `/opt/conda/bin/python /snn4imagenet/testSNN_script.py --modelname '%s' --modelpath '/dataset' --modeldescription '%s'`
  28. BrainScoreCommand = `bash /brainscore/brainscore_test_par4shSrcipt.sh -b '%s' -n '%s' -p '/dataset' -d '%s'`
  29. SubTaskName = "task1"
  30. Success = "S000"
  31. DefaultBranchName = "master"
  32. )
  33. var (
  34. ResourceSpecs *models.ResourceSpecs
  35. TrainResourceSpecs *models.ResourceSpecs
  36. SpecialPools *models.SpecialPools
  37. )
  38. type GenerateCloudBrainTaskReq struct {
  39. Ctx *context.Context
  40. DisplayJobName string
  41. JobName string
  42. Image string
  43. Command string
  44. CodePath string
  45. ModelPath string
  46. BenchmarkPath string
  47. Snn4ImageNetPath string
  48. BrainScorePath string
  49. JobType string
  50. GpuQueue string
  51. Description string
  52. BranchName string
  53. BootFile string
  54. Params string
  55. CommitID string
  56. Uuids string
  57. DatasetNames string
  58. DatasetInfos map[string]models.DatasetInfo
  59. BenchmarkTypeID int
  60. BenchmarkChildTypeID int
  61. ResourceSpecId int
  62. }
  63. func isAdminOrOwnerOrJobCreater(ctx *context.Context, job *models.Cloudbrain, err error) bool {
  64. if !ctx.IsSigned {
  65. return false
  66. }
  67. if err != nil {
  68. return ctx.IsUserRepoOwner() || ctx.IsUserSiteAdmin()
  69. } else {
  70. return ctx.IsUserRepoOwner() || ctx.IsUserSiteAdmin() || ctx.User.ID == job.UserID
  71. }
  72. }
  73. func CanDeleteJob(ctx *context.Context, job *models.Cloudbrain) bool {
  74. return isAdminOrOwnerOrJobCreater(ctx, job, nil)
  75. }
  76. func CanCreateOrDebugJob(ctx *context.Context) bool {
  77. if !ctx.IsSigned {
  78. return false
  79. }
  80. return ctx.Repo.CanWrite(models.UnitTypeCloudBrain)
  81. }
  82. func CanModifyJob(ctx *context.Context, job *models.Cloudbrain) bool {
  83. return isAdminOrJobCreater(ctx, job, nil)
  84. }
  85. func isAdminOrJobCreater(ctx *context.Context, job *models.Cloudbrain, err error) bool {
  86. if !ctx.IsSigned {
  87. return false
  88. }
  89. if err != nil {
  90. return ctx.IsUserSiteAdmin()
  91. } else {
  92. return ctx.IsUserSiteAdmin() || ctx.User.ID == job.UserID
  93. }
  94. }
  95. func isAdminOrImageCreater(ctx *context.Context, image *models.Image, err error) bool {
  96. if !ctx.IsSigned {
  97. return false
  98. }
  99. if err != nil {
  100. return ctx.IsUserSiteAdmin()
  101. } else {
  102. return ctx.IsUserSiteAdmin() || ctx.User.ID == image.UID
  103. }
  104. }
  105. func AdminOrOwnerOrJobCreaterRight(ctx *context.Context) {
  106. var ID = ctx.Params(":id")
  107. job, err := models.GetCloudbrainByID(ID)
  108. if err != nil {
  109. log.Error("GetCloudbrainByID failed:%v", err.Error())
  110. ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
  111. }
  112. ctx.Cloudbrain = job
  113. if !isAdminOrOwnerOrJobCreater(ctx, job, err) {
  114. log.Error("!isAdminOrOwnerOrJobCreater error:%v", err.Error())
  115. ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
  116. }
  117. }
  118. func AdminOrJobCreaterRight(ctx *context.Context) {
  119. var ID = ctx.Params(":id")
  120. job, err := models.GetCloudbrainByID(ID)
  121. if err != nil {
  122. log.Error("GetCloudbrainByID failed:%v", err.Error())
  123. ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
  124. }
  125. ctx.Cloudbrain = job
  126. if !isAdminOrJobCreater(ctx, job, err) {
  127. log.Error("!isAdminOrJobCreater error:%v", err.Error())
  128. ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
  129. }
  130. }
  131. func AdminOrOwnerOrJobCreaterRightForTrain(ctx *context.Context) {
  132. var jobID = ctx.Params(":jobid")
  133. job, err := models.GetCloudbrainByJobID(jobID)
  134. if err != nil {
  135. log.Error("GetCloudbrainByJobID failed:%v", err.Error())
  136. ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
  137. }
  138. ctx.Cloudbrain = job
  139. if !isAdminOrOwnerOrJobCreater(ctx, job, err) {
  140. log.Error("!isAdminOrOwnerOrJobCreater failed:%v", err.Error())
  141. ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
  142. }
  143. }
  144. func AdminOrJobCreaterRightForTrain(ctx *context.Context) {
  145. var jobID = ctx.Params(":jobid")
  146. job, err := models.GetCloudbrainByJobID(jobID)
  147. if err != nil {
  148. log.Error("GetCloudbrainByJobID failed:%v", err.Error())
  149. ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
  150. }
  151. ctx.Cloudbrain = job
  152. if !isAdminOrJobCreater(ctx, job, err) {
  153. log.Error("!isAdminOrJobCreater errot:%v", err.Error())
  154. ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
  155. }
  156. }
  157. func AdminOrImageCreaterRight(ctx *context.Context) {
  158. id, err := strconv.ParseInt(ctx.Params(":id"), 10, 64)
  159. var image *models.Image
  160. if err != nil {
  161. log.Error("Get Image by ID failed:%v", err.Error())
  162. } else {
  163. image, err = models.GetImageByID(id)
  164. if err != nil {
  165. log.Error("Get Image by ID failed:%v", err.Error())
  166. return
  167. }
  168. }
  169. if !isAdminOrImageCreater(ctx, image, err) {
  170. log.Error("!isAdminOrImageCreater error:%v", err.Error())
  171. ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
  172. }
  173. }
  174. func GenerateTask(req GenerateCloudBrainTaskReq) error {
  175. var resourceSpec *models.ResourceSpec
  176. var versionCount int
  177. if req.JobType == string(models.JobTypeTrain) {
  178. versionCount = 1
  179. if TrainResourceSpecs == nil {
  180. json.Unmarshal([]byte(setting.TrainResourceSpecs), &TrainResourceSpecs)
  181. }
  182. for _, spec := range TrainResourceSpecs.ResourceSpec {
  183. if req.ResourceSpecId == spec.Id {
  184. resourceSpec = spec
  185. break
  186. }
  187. }
  188. } else {
  189. if ResourceSpecs == nil {
  190. json.Unmarshal([]byte(setting.ResourceSpecs), &ResourceSpecs)
  191. }
  192. for _, spec := range ResourceSpecs.ResourceSpec {
  193. if req.ResourceSpecId == spec.Id {
  194. resourceSpec = spec
  195. break
  196. }
  197. }
  198. }
  199. //如果没有匹配到spec信息,尝试从专属资源池获取
  200. if resourceSpec == nil && SpecialPools != nil {
  201. for _, specialPool := range SpecialPools.Pools {
  202. if resourceSpec != nil {
  203. break
  204. }
  205. if specialPool.ResourceSpec != nil {
  206. if IsElementExist(specialPool.JobType, req.JobType) && IsQueueInSpecialtPool(specialPool.Pool, req.GpuQueue) {
  207. for _, spec := range specialPool.ResourceSpec {
  208. if req.ResourceSpecId == spec.Id {
  209. resourceSpec = spec
  210. break
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. if resourceSpec == nil {
  218. log.Error("no such resourceSpecId(%d)", req.ResourceSpecId, req.Ctx.Data["MsgID"])
  219. return errors.New("no such resourceSpec")
  220. }
  221. volumes := []models.Volume{
  222. {
  223. HostPath: models.StHostPath{
  224. Path: req.CodePath,
  225. MountPath: CodeMountPath,
  226. ReadOnly: false,
  227. },
  228. },
  229. {
  230. HostPath: models.StHostPath{
  231. Path: req.ModelPath,
  232. MountPath: ModelMountPath,
  233. ReadOnly: false,
  234. },
  235. },
  236. {
  237. HostPath: models.StHostPath{
  238. Path: req.BenchmarkPath,
  239. MountPath: BenchMarkMountPath,
  240. ReadOnly: true,
  241. },
  242. },
  243. {
  244. HostPath: models.StHostPath{
  245. Path: req.Snn4ImageNetPath,
  246. MountPath: Snn4imagenetMountPath,
  247. ReadOnly: true,
  248. },
  249. },
  250. {
  251. HostPath: models.StHostPath{
  252. Path: req.BrainScorePath,
  253. MountPath: BrainScoreMountPath,
  254. ReadOnly: true,
  255. },
  256. },
  257. }
  258. if len(req.DatasetInfos) == 1 {
  259. volumes = append(volumes, models.Volume{
  260. HostPath: models.StHostPath{
  261. Path: req.DatasetInfos[req.Uuids].DataLocalPath,
  262. MountPath: DataSetMountPath,
  263. ReadOnly: true,
  264. },
  265. })
  266. } else {
  267. for _, dataset := range req.DatasetInfos {
  268. volumes = append(volumes, models.Volume{
  269. HostPath: models.StHostPath{
  270. Path: dataset.DataLocalPath,
  271. MountPath: DataSetMountPath + "/" + dataset.Name,
  272. ReadOnly: true,
  273. },
  274. })
  275. }
  276. }
  277. createTime := timeutil.TimeStampNow()
  278. jobResult, err := CreateJob(req.JobName, models.CreateJobParams{
  279. JobName: req.JobName,
  280. RetryCount: 1,
  281. GpuType: req.GpuQueue,
  282. Image: req.Image,
  283. TaskRoles: []models.TaskRole{
  284. {
  285. Name: SubTaskName,
  286. TaskNumber: 1,
  287. MinSucceededTaskCount: 1,
  288. MinFailedTaskCount: 1,
  289. CPUNumber: resourceSpec.CpuNum,
  290. GPUNumber: resourceSpec.GpuNum,
  291. MemoryMB: resourceSpec.MemMiB,
  292. ShmMB: resourceSpec.ShareMemMiB,
  293. Command: req.Command,
  294. NeedIBDevice: false,
  295. IsMainRole: false,
  296. UseNNI: false,
  297. },
  298. },
  299. Volumes: volumes,
  300. })
  301. if err != nil {
  302. log.Error("CreateJob failed:", err.Error(), req.Ctx.Data["MsgID"])
  303. return err
  304. }
  305. if jobResult.Code != Success {
  306. log.Error("CreateJob(%s) failed:%s", req.JobName, jobResult.Msg, req.Ctx.Data["MsgID"])
  307. return errors.New(jobResult.Msg)
  308. }
  309. var jobID = jobResult.Payload["jobId"].(string)
  310. err = models.CreateCloudbrain(&models.Cloudbrain{
  311. Status: string(models.JobWaiting),
  312. UserID: req.Ctx.User.ID,
  313. RepoID: req.Ctx.Repo.Repository.ID,
  314. JobID: jobID,
  315. JobName: req.JobName,
  316. DisplayJobName: req.DisplayJobName,
  317. SubTaskName: SubTaskName,
  318. JobType: req.JobType,
  319. Type: models.TypeCloudBrainOne,
  320. Uuid: req.Uuids,
  321. Image: req.Image,
  322. GpuQueue: req.GpuQueue,
  323. ResourceSpecId: req.ResourceSpecId,
  324. ComputeResource: models.GPUResource,
  325. BenchmarkTypeID: req.BenchmarkTypeID,
  326. BenchmarkChildTypeID: req.BenchmarkChildTypeID,
  327. Description: req.Description,
  328. IsLatestVersion: "1",
  329. VersionCount: versionCount,
  330. BranchName: req.BranchName,
  331. BootFile: req.BootFile,
  332. DatasetName: req.DatasetNames,
  333. Parameters: req.Params,
  334. CreatedUnix: createTime,
  335. UpdatedUnix: createTime,
  336. CommitID: req.CommitID,
  337. })
  338. if err != nil {
  339. return err
  340. }
  341. task, err := models.GetCloudbrainByJobID(jobID)
  342. if err != nil {
  343. log.Error("GetCloudbrainByJobID failed: %v", err.Error())
  344. return err
  345. }
  346. stringId := strconv.FormatInt(task.ID, 10)
  347. if IsBenchmarkJob(req.JobType) {
  348. notification.NotifyOtherTask(req.Ctx.User, req.Ctx.Repo.Repository, stringId, req.DisplayJobName, models.ActionCreateBenchMarkTask)
  349. } else if string(models.JobTypeTrain) == req.JobType {
  350. notification.NotifyOtherTask(req.Ctx.User, req.Ctx.Repo.Repository, jobID, req.DisplayJobName, models.ActionCreateGPUTrainTask)
  351. } else {
  352. notification.NotifyOtherTask(req.Ctx.User, req.Ctx.Repo.Repository, stringId, req.DisplayJobName, models.ActionCreateDebugGPUTask)
  353. }
  354. return nil
  355. }
  356. func IsBenchmarkJob(jobType string) bool {
  357. return string(models.JobTypeBenchmark) == jobType || string(models.JobTypeBrainScore) == jobType || string(models.JobTypeSnn4imagenet) == jobType
  358. }
  359. func RestartTask(ctx *context.Context, task *models.Cloudbrain, newID *string) error {
  360. jobName := task.JobName
  361. var resourceSpec *models.ResourceSpec
  362. if ResourceSpecs == nil {
  363. json.Unmarshal([]byte(setting.ResourceSpecs), &ResourceSpecs)
  364. }
  365. for _, spec := range ResourceSpecs.ResourceSpec {
  366. if task.ResourceSpecId == spec.Id {
  367. resourceSpec = spec
  368. }
  369. }
  370. if resourceSpec == nil {
  371. log.Error("no such resourceSpecId(%d)", task.ResourceSpecId, ctx.Data["MsgID"])
  372. return errors.New("no such resourceSpec")
  373. }
  374. datasetInfos, _, err := models.GetDatasetInfo(task.Uuid)
  375. if err != nil {
  376. log.Error("GetDatasetInfo failed:%v", err, ctx.Data["MsgID"])
  377. return err
  378. }
  379. volumes := []models.Volume{
  380. {
  381. HostPath: models.StHostPath{
  382. Path: storage.GetMinioPath(jobName, CodeMountPath+"/"),
  383. MountPath: CodeMountPath,
  384. ReadOnly: false,
  385. },
  386. },
  387. {
  388. HostPath: models.StHostPath{
  389. Path: storage.GetMinioPath(jobName, ModelMountPath+"/"),
  390. MountPath: ModelMountPath,
  391. ReadOnly: false,
  392. },
  393. },
  394. {
  395. HostPath: models.StHostPath{
  396. Path: storage.GetMinioPath(jobName, BenchMarkMountPath+"/"),
  397. MountPath: BenchMarkMountPath,
  398. ReadOnly: true,
  399. },
  400. },
  401. {
  402. HostPath: models.StHostPath{
  403. Path: storage.GetMinioPath(jobName, Snn4imagenetMountPath+"/"),
  404. MountPath: Snn4imagenetMountPath,
  405. ReadOnly: true,
  406. },
  407. },
  408. {
  409. HostPath: models.StHostPath{
  410. Path: storage.GetMinioPath(jobName, BrainScoreMountPath+"/"),
  411. MountPath: BrainScoreMountPath,
  412. ReadOnly: true,
  413. },
  414. },
  415. }
  416. if len(datasetInfos) == 1 {
  417. volumes = append(volumes, models.Volume{
  418. HostPath: models.StHostPath{
  419. Path: datasetInfos[task.Uuid].DataLocalPath,
  420. MountPath: DataSetMountPath,
  421. ReadOnly: true,
  422. },
  423. })
  424. } else {
  425. for _, dataset := range datasetInfos {
  426. volumes = append(volumes, models.Volume{
  427. HostPath: models.StHostPath{
  428. Path: dataset.DataLocalPath,
  429. MountPath: DataSetMountPath + "/" + dataset.Name,
  430. ReadOnly: true,
  431. },
  432. })
  433. }
  434. }
  435. createTime := timeutil.TimeStampNow()
  436. jobResult, err := CreateJob(jobName, models.CreateJobParams{
  437. JobName: jobName,
  438. RetryCount: 1,
  439. GpuType: task.GpuQueue,
  440. Image: task.Image,
  441. TaskRoles: []models.TaskRole{
  442. {
  443. Name: SubTaskName,
  444. TaskNumber: 1,
  445. MinSucceededTaskCount: 1,
  446. MinFailedTaskCount: 1,
  447. CPUNumber: resourceSpec.CpuNum,
  448. GPUNumber: resourceSpec.GpuNum,
  449. MemoryMB: resourceSpec.MemMiB,
  450. ShmMB: resourceSpec.ShareMemMiB,
  451. Command: Command,
  452. NeedIBDevice: false,
  453. IsMainRole: false,
  454. UseNNI: false,
  455. },
  456. },
  457. Volumes: volumes,
  458. })
  459. if err != nil {
  460. log.Error("CreateJob failed:%v", err.Error(), ctx.Data["MsgID"])
  461. return err
  462. }
  463. if jobResult.Code != Success {
  464. log.Error("CreateJob(%s) failed:%s", jobName, jobResult.Msg, ctx.Data["MsgID"])
  465. return errors.New(jobResult.Msg)
  466. }
  467. var jobID = jobResult.Payload["jobId"].(string)
  468. newTask := &models.Cloudbrain{
  469. Status: string(models.JobWaiting),
  470. UserID: task.UserID,
  471. RepoID: task.RepoID,
  472. JobID: jobID,
  473. JobName: task.JobName,
  474. DisplayJobName: task.DisplayJobName,
  475. SubTaskName: task.SubTaskName,
  476. JobType: task.JobType,
  477. Type: task.Type,
  478. Uuid: task.Uuid,
  479. DatasetName: task.DatasetName,
  480. Image: task.Image,
  481. GpuQueue: task.GpuQueue,
  482. ResourceSpecId: task.ResourceSpecId,
  483. ComputeResource: task.ComputeResource,
  484. CreatedUnix: createTime,
  485. UpdatedUnix: createTime,
  486. BranchName: task.BranchName,
  487. }
  488. err = models.RestartCloudbrain(task, newTask)
  489. if err != nil {
  490. log.Error("RestartCloudbrain(%s) failed:%v", jobName, err.Error(), ctx.Data["MsgID"])
  491. return err
  492. }
  493. stringId := strconv.FormatInt(newTask.ID, 10)
  494. *newID = stringId
  495. notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, stringId, task.DisplayJobName, models.ActionCreateDebugGPUTask)
  496. return nil
  497. }
  498. func InitSpecialPool() {
  499. if SpecialPools == nil && setting.SpecialPools != "" {
  500. json.Unmarshal([]byte(setting.SpecialPools), &SpecialPools)
  501. }
  502. }
  503. func IsResourceSpecInSpecialPool(resourceSpecs []*models.ResourceSpec, resourceSpecId int) bool {
  504. if resourceSpecs == nil || len(resourceSpecs) == 0 {
  505. return true
  506. }
  507. for _, v := range resourceSpecs {
  508. if v.Id == resourceSpecId {
  509. return true
  510. }
  511. }
  512. return false
  513. }
  514. func IsQueueInSpecialtPool(pool []*models.GpuInfo, queue string) bool {
  515. for _, v := range pool {
  516. if v.Queue == queue {
  517. return true
  518. }
  519. }
  520. return false
  521. }
  522. func IsElementExist(s []string, str string) bool {
  523. for _, v := range s {
  524. if v == str {
  525. return true
  526. }
  527. }
  528. return false
  529. }