mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-15 23:46:12 +00:00
Add used and total GPU vram variables
This commit is contained in:
+12
-4
@@ -24,7 +24,8 @@ type GPU struct {
|
||||
Product string
|
||||
Subsystem string
|
||||
Driver string
|
||||
VRAM string
|
||||
VramTotal string
|
||||
VramUsed string
|
||||
}
|
||||
|
||||
type Monitor struct {
|
||||
@@ -136,11 +137,17 @@ func GetGPUModels(hiddenGPUs []int) []GPU {
|
||||
}
|
||||
|
||||
// Get VRAM
|
||||
vram := "Unknown"
|
||||
vramTotal := "Unknown"
|
||||
bytes, err := os.ReadFile("/sys/class/drm/card" + strconv.Itoa(gpu.Index) + "/device/mem_info_vram_total")
|
||||
if err == nil {
|
||||
vramUint, _ := strconv.ParseUint(strings.TrimSpace(string(bytes)), 10, 64)
|
||||
vram = FormatBytes(vramUint)
|
||||
vramTotal = FormatBytes(vramUint)
|
||||
}
|
||||
vramUsed := "Unknown"
|
||||
bytes, err = os.ReadFile("/sys/class/drm/card" + strconv.Itoa(gpu.Index) + "/device/mem_info_vram_used")
|
||||
if err == nil {
|
||||
vramUint, _ := strconv.ParseUint(strings.TrimSpace(string(bytes)), 10, 64)
|
||||
vramUsed = FormatBytes(vramUint)
|
||||
}
|
||||
|
||||
ret = append(ret, GPU{
|
||||
@@ -150,7 +157,8 @@ func GetGPUModels(hiddenGPUs []int) []GPU {
|
||||
Product: gpu.DeviceInfo.Product.Name,
|
||||
Subsystem: gpu.DeviceInfo.Subsystem.Name,
|
||||
Driver: gpu.DeviceInfo.Driver,
|
||||
VRAM: vram,
|
||||
VramTotal: vramTotal,
|
||||
VramUsed: vramUsed,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -246,8 +246,10 @@ func initializeModuleMap() {
|
||||
return gpu.Subsystem
|
||||
case "GPU_DRIVER":
|
||||
return gpu.Driver
|
||||
case "GPU_VRAM":
|
||||
return gpu.VRAM
|
||||
case "GPU_VRAM_TOTAL":
|
||||
return gpu.VramTotal
|
||||
case "GPU_VRAM_USED":
|
||||
return gpu.VramUsed
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user