Fix GPU index numbering, promote the GPU ID

This commit is contained in:
Ingo Oppermann
2024-10-31 14:59:22 +01:00
parent bfb54ca177
commit d591a2383e
5 changed files with 21 additions and 19 deletions

View File

@@ -32,6 +32,7 @@ func New(ngpu int) *MockPSUtil {
for i := 0; i < ngpu; i++ {
u.GPUInfo = append(u.GPUInfo, psutil.GPUInfo{
Index: i,
ID: "00000000:01:00.0",
Name: "L4",
MemoryTotal: 24 * 1024 * 1024 * 1024,
MemoryUsed: uint64(12+i) * 1024 * 1024 * 1024,

View File

@@ -22,13 +22,11 @@ func (p *proc) Info() (resources.ProcessInfo, error) {
},
Memory: 197,
GPU: resources.ProcessInfoGPU{
Index: 0,
Name: "L4",
MemoryTotal: 128,
MemoryUsed: 91,
Usage: 3,
Encoder: 9,
Decoder: 5,
Index: 0,
MemoryUsed: 91,
Usage: 3,
Encoder: 9,
Decoder: 5,
},
}

View File

@@ -71,6 +71,7 @@ type CPUInfo struct {
type GPUInfo struct {
Index int // Index of the GPU
ID string // Physical ID of the GPU (not populated for a specific process)
Name string // Name of the GPU (not populated for a specific process)
MemoryTotal uint64 // bytes (not populated for a specific process)
@@ -638,8 +639,10 @@ func (u *util) GPU() ([]GPUInfo, error) {
stats := []GPUInfo{}
for _, nv := range nvstats {
for i, nv := range nvstats {
stats = append(stats, GPUInfo{
Index: i,
ID: nv.ID,
Name: nv.Name,
MemoryTotal: nv.MemoryTotal,
MemoryUsed: nv.MemoryUsed,

View File

@@ -63,6 +63,7 @@ type GPUInfo struct {
type GPUInfoStat struct {
Index int
ID string
Name string
// Memory
@@ -566,6 +567,7 @@ func (r *resources) Info() Info {
for i, g := range gpustat {
gpuinfo.GPU = append(gpuinfo.GPU, GPUInfoStat{
Index: g.Index,
ID: g.ID,
Name: g.Name,
MemoryTotal: g.MemoryTotal,
MemoryUsed: g.MemoryUsed,
@@ -666,11 +668,9 @@ type ProcessInfoCPU struct {
}
type ProcessInfoGPU struct {
Index int // Index of the GPU
Name string // Name of the GPU (not populated for a specific process)
Index int // Index of the GPU
MemoryTotal uint64 // bytes (not populated for a specific process)
MemoryUsed uint64 // bytes
MemoryUsed uint64 // bytes
Usage float64 // percent 0-100
Encoder float64 // percent 0-100
@@ -708,13 +708,11 @@ func (p *process) Info() (ProcessInfo, error) {
},
Memory: mem,
GPU: ProcessInfoGPU{
Index: gpu.Index,
Name: gpu.Name,
MemoryTotal: gpu.MemoryTotal,
MemoryUsed: gpu.MemoryUsed,
Usage: gpu.Usage,
Encoder: gpu.Encoder,
Decoder: gpu.Decoder,
Index: gpu.Index,
MemoryUsed: gpu.MemoryUsed,
Usage: gpu.Usage,
Encoder: gpu.Encoder,
Decoder: gpu.Decoder,
},
}

View File

@@ -828,6 +828,7 @@ func TestInfo(t *testing.T) {
NGPU: 2,
GPU: []GPUInfoStat{{
Index: 0,
ID: "00000000:01:00.0",
Name: "L4",
MemoryTotal: 24 * 1024 * 1024 * 1024,
MemoryUsed: 12 * 1024 * 1024 * 1024,
@@ -839,6 +840,7 @@ func TestInfo(t *testing.T) {
UsageLimit: 11,
}, {
Index: 1,
ID: "00000000:01:00.0",
Name: "L4",
MemoryTotal: 24 * 1024 * 1024 * 1024,
MemoryUsed: 13 * 1024 * 1024 * 1024,