Create GPU index in actual driver

This commit is contained in:
Ingo Oppermann
2024-10-31 15:23:24 +01:00
parent d591a2383e
commit abc821fe4b
4 changed files with 7 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ type Process struct {
}
type Stats struct {
Index int
ID string
Name string
Architecture string

View File

@@ -444,8 +444,9 @@ func (n *nvidia) Stats() ([]gpu.Stats, error) {
return stats, n.err
}
for _, nv := range n.stats.GPU {
for i, nv := range n.stats.GPU {
s := gpu.Stats{
Index: i,
ID: nv.ID,
Name: nv.Name,
Architecture: nv.Architecture,

View File

@@ -324,6 +324,7 @@ func TestNvidiaGPUStats(t *testing.T) {
require.NoError(t, err)
require.Equal(t, []gpu.Stats{
{
Index: 0,
ID: "00000000:01:00.0",
Name: "NVIDIA L4",
Architecture: "Ada Lovelace",
@@ -360,6 +361,7 @@ func TestNvidiaGPUStats(t *testing.T) {
},
},
{
Index: 1,
ID: "00000000:C1:00.0",
Name: "NVIDIA L4",
Architecture: "Ada Lovelace",

View File

@@ -639,9 +639,9 @@ func (u *util) GPU() ([]GPUInfo, error) {
stats := []GPUInfo{}
for i, nv := range nvstats {
for _, nv := range nvstats {
stats = append(stats, GPUInfo{
Index: i,
Index: nv.Index,
ID: nv.ID,
Name: nv.Name,
MemoryTotal: nv.MemoryTotal,