Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
power-node
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
power-node
Commits
5ca34c42
Commit
5ca34c42
authored
Jun 06, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
foundSeq
parent
57f6f27c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
16 deletions
+36
-16
const.go
models/const.go
+1
-0
docker.go
operate/docker.go
+35
-16
No files found.
models/const.go
View file @
5ca34c42
...
@@ -30,4 +30,5 @@ const (
...
@@ -30,4 +30,5 @@ const (
OneHour
=
1
OneHour
=
1
OneMinutes
=
1
OneMinutes
=
1
TwoMinutes
=
2
TwoMinutes
=
2
DefaultGpuSeq
=
999
)
)
operate/docker.go
View file @
5ca34c42
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"example.com/m/db"
"example.com/m/db"
"example.com/m/log"
"example.com/m/log"
"example.com/m/models"
"example.com/m/models"
"example.com/m/utils"
"fmt"
"fmt"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/container"
...
@@ -391,36 +392,54 @@ func (d *DockerOp) getContainerInfo(id string) (types.Container, error) {
...
@@ -391,36 +392,54 @@ func (d *DockerOp) getContainerInfo(id string) (types.Container, error) {
}
}
func
(
d
*
DockerOp
)
checkGpuUsage
(
info
*
nodemanagerV2
.
HardwareInfo
,
modelInfo
*
models
.
ModelInfo
,
dockerCmd
*
models
.
DockerCmd
)
int32
{
func
(
d
*
DockerOp
)
checkGpuUsage
(
info
*
nodemanagerV2
.
HardwareInfo
,
modelInfo
*
models
.
ModelInfo
,
dockerCmd
*
models
.
DockerCmd
)
int32
{
envMap
:=
make
(
map
[
string
]
string
,
0
)
var
res
int32
=
models
.
DefaultGpuSeq
var
res
int32
=
999
// 匹配首次启动模型的硬件信息数据
gpu
:=
info
.
GPU
gpu
:=
info
.
GPU
isMatch
:=
false
isMatch
:=
false
for
_
,
gpuInfo
:=
range
gpu
{
for
_
,
gpuInfo
:=
range
gpu
{
if
gpuInfo
.
MemFree
>
modelInfo
.
RunningMem
{
if
gpuInfo
.
MemFree
>
modelInfo
.
RunningMem
{
envMap
[
models
.
CudaEnv
]
=
strconv
.
FormatInt
(
int64
(
gpuInfo
.
Seq
),
10
)
res
=
gpuInfo
.
Seq
res
=
gpuInfo
.
Seq
isMatch
=
true
isMatch
=
true
break
break
}
}
}
}
if
!
isMatch
{
if
!
isMatch
{
runningModel
:=
db
.
GetRunningModel
()
res
=
d
.
foundSeq
(
modelInfo
)
if
len
(
runningModel
)
==
0
{
}
return
0
return
res
}
func
(
d
*
DockerOp
)
foundSeq
(
modelInfo
*
models
.
ModelInfo
)
int32
{
var
res
int32
=
models
.
DefaultGpuSeq
isMatch
:=
false
// 获取当前启动的模型
runningModel
:=
d
.
ListContainer
()
for
_
,
containerInfo
:=
range
runningModel
{
runningModelInfo
,
err
:=
db
.
GetModel
(
containerInfo
.
Image
)
if
err
!=
nil
||
runningModelInfo
==
nil
{
continue
}
}
for
_
,
modelInfo
:=
range
runningModel
{
if
runningModelInfo
.
RunningMem
>
modelInfo
.
RunningMem
{
if
modelInfo
.
RunningMem
>
modelInfo
.
RunningMem
{
isMatch
=
true
isMatch
=
true
d
.
StopContainer
(
containerInfo
.
ID
)
d
.
StopContainer
(
modelInfo
.
ContainerId
)
if
modelInfo
.
GpuSeq
!=
models
.
DefaultGpuSeq
{
envMap
[
models
.
CudaEnv
]
=
strconv
.
FormatInt
(
int64
(
modelInfo
.
GpuSeq
),
10
)
res
=
modelInfo
.
GpuSeq
break
}
else
{
time
.
Sleep
(
time
.
Second
*
2
)
hardwareInfo
:=
utils
.
GetHardwareInfo
(
conf
.
GetConfig
()
.
HardwareUrl
)
for
_
,
gpuInfo
:=
range
hardwareInfo
.
Data
.
Gpus
{
if
gpuInfo
.
MemFree
>
modelInfo
.
RunningMem
{
res
=
gpuInfo
.
Seq
isMatch
=
true
break
}
}
}
}
break
}
}
}
}
if
isMatch
{
if
!
isMatch
{
//nm.ModelRunningBeforeMem[modelInfo.ImageName] = dockerCmd.RunningBeforeMem
d
.
foundSeq
(
modelInfo
)
gpuSeq
,
_
:=
strconv
.
ParseInt
(
dockerCmd
.
EnvMap
[
models
.
CudaEnv
],
10
,
32
)
res
=
int32
(
gpuSeq
)
}
}
return
res
return
res
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment