diff --git a/internal/mock/psutil/psutil.go b/internal/mock/psutil/psutil.go index c0f37048..e03af2a0 100644 --- a/internal/mock/psutil/psutil.go +++ b/internal/mock/psutil/psutil.go @@ -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, diff --git a/process/limiter_test.go b/process/limiter_test.go index 56813958..bcb11045 100644 --- a/process/limiter_test.go +++ b/process/limiter_test.go @@ -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, }, } diff --git a/resources/psutil/psutil.go b/resources/psutil/psutil.go index c231792b..6dc13982 100644 --- a/resources/psutil/psutil.go +++ b/resources/psutil/psutil.go @@ -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, diff --git a/resources/resources.go b/resources/resources.go index 1e322a14..33edd2f2 100644 --- a/resources/resources.go +++ b/resources/resources.go @@ -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, }, } diff --git a/resources/resources_test.go b/resources/resources_test.go index 77bb7116..dba43503 100644 --- a/resources/resources_test.go +++ b/resources/resources_test.go @@ -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,