mirror of
https://github.com/datarhei/core.git
synced 2025-10-08 09:20:16 +08:00
Create GPU index in actual driver
This commit is contained in:
@@ -12,6 +12,7 @@ type Process struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Stats struct {
|
type Stats struct {
|
||||||
|
Index int
|
||||||
ID string
|
ID string
|
||||||
Name string
|
Name string
|
||||||
Architecture string
|
Architecture string
|
||||||
|
@@ -444,8 +444,9 @@ func (n *nvidia) Stats() ([]gpu.Stats, error) {
|
|||||||
return stats, n.err
|
return stats, n.err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, nv := range n.stats.GPU {
|
for i, nv := range n.stats.GPU {
|
||||||
s := gpu.Stats{
|
s := gpu.Stats{
|
||||||
|
Index: i,
|
||||||
ID: nv.ID,
|
ID: nv.ID,
|
||||||
Name: nv.Name,
|
Name: nv.Name,
|
||||||
Architecture: nv.Architecture,
|
Architecture: nv.Architecture,
|
||||||
|
@@ -324,6 +324,7 @@ func TestNvidiaGPUStats(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, []gpu.Stats{
|
require.Equal(t, []gpu.Stats{
|
||||||
{
|
{
|
||||||
|
Index: 0,
|
||||||
ID: "00000000:01:00.0",
|
ID: "00000000:01:00.0",
|
||||||
Name: "NVIDIA L4",
|
Name: "NVIDIA L4",
|
||||||
Architecture: "Ada Lovelace",
|
Architecture: "Ada Lovelace",
|
||||||
@@ -360,6 +361,7 @@ func TestNvidiaGPUStats(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Index: 1,
|
||||||
ID: "00000000:C1:00.0",
|
ID: "00000000:C1:00.0",
|
||||||
Name: "NVIDIA L4",
|
Name: "NVIDIA L4",
|
||||||
Architecture: "Ada Lovelace",
|
Architecture: "Ada Lovelace",
|
||||||
|
@@ -639,9 +639,9 @@ func (u *util) GPU() ([]GPUInfo, error) {
|
|||||||
|
|
||||||
stats := []GPUInfo{}
|
stats := []GPUInfo{}
|
||||||
|
|
||||||
for i, nv := range nvstats {
|
for _, nv := range nvstats {
|
||||||
stats = append(stats, GPUInfo{
|
stats = append(stats, GPUInfo{
|
||||||
Index: i,
|
Index: nv.Index,
|
||||||
ID: nv.ID,
|
ID: nv.ID,
|
||||||
Name: nv.Name,
|
Name: nv.Name,
|
||||||
MemoryTotal: nv.MemoryTotal,
|
MemoryTotal: nv.MemoryTotal,
|
||||||
|
Reference in New Issue
Block a user