Skip to content

Commit

Permalink
Create GPU index in actual driver
Browse files Browse the repository at this point in the history
  • Loading branch information
ioppermann committed Oct 31, 2024
1 parent d591a23 commit abc821f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions resources/psutil/gpu/gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Process struct {
}

type Stats struct {
Index int
ID string
Name string
Architecture string
Expand Down
3 changes: 2 additions & 1 deletion resources/psutil/gpu/nvidia/nvidia.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions resources/psutil/gpu/nvidia/nvidia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -360,6 +361,7 @@ func TestNvidiaGPUStats(t *testing.T) {
},
},
{
Index: 1,
ID: "00000000:C1:00.0",
Name: "NVIDIA L4",
Architecture: "Ada Lovelace",
Expand Down
4 changes: 2 additions & 2 deletions resources/psutil/psutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit abc821f

Please sign in to comment.