mirror of
https://github.com/henrygd/beszel.git
synced 2026-04-26 14:31:50 +02:00
amd gpu: small refactor + trim "series" from device name
This commit is contained in:
@@ -103,10 +103,8 @@ func (gm *GPUManager) updateAmdGpuData(cardPath string) bool {
|
|||||||
|
|
||||||
// Read all sysfs values first (no lock needed - these can be slow)
|
// Read all sysfs values first (no lock needed - these can be slow)
|
||||||
usage, usageErr := readSysfsFloat(filepath.Join(devicePath, "gpu_busy_percent"))
|
usage, usageErr := readSysfsFloat(filepath.Join(devicePath, "gpu_busy_percent"))
|
||||||
vramUsed, memUsedErr := readSysfsFloat(filepath.Join(devicePath, "mem_info_vram_used"))
|
memUsed, memUsedErr := readSysfsFloat(filepath.Join(devicePath, "mem_info_vram_used"))
|
||||||
vramTotal, _ := readSysfsFloat(filepath.Join(devicePath, "mem_info_vram_total"))
|
memTotal, _ := readSysfsFloat(filepath.Join(devicePath, "mem_info_vram_total"))
|
||||||
memUsed := vramUsed
|
|
||||||
memTotal := vramTotal
|
|
||||||
// if gtt is present, add it to the memory used and total (https://github.com/henrygd/beszel/issues/1569#issuecomment-3837640484)
|
// if gtt is present, add it to the memory used and total (https://github.com/henrygd/beszel/issues/1569#issuecomment-3837640484)
|
||||||
if gttUsed, err := readSysfsFloat(filepath.Join(devicePath, "mem_info_gtt_used")); err == nil && gttUsed > 0 {
|
if gttUsed, err := readSysfsFloat(filepath.Join(devicePath, "mem_info_gtt_used")); err == nil && gttUsed > 0 {
|
||||||
if gttTotal, err := readSysfsFloat(filepath.Join(devicePath, "mem_info_gtt_total")); err == nil {
|
if gttTotal, err := readSysfsFloat(filepath.Join(devicePath, "mem_info_gtt_total")); err == nil {
|
||||||
@@ -243,7 +241,10 @@ func getCachedAmdgpuName(deviceID, revisionID string) (name string, found bool,
|
|||||||
|
|
||||||
// normalizeAmdgpuName trims standard suffixes from AMDGPU product names.
|
// normalizeAmdgpuName trims standard suffixes from AMDGPU product names.
|
||||||
func normalizeAmdgpuName(name string) string {
|
func normalizeAmdgpuName(name string) string {
|
||||||
return strings.TrimSuffix(strings.TrimSpace(name), " Graphics")
|
for _, suffix := range []string{" Graphics", " Series"} {
|
||||||
|
name = strings.TrimSuffix(name, suffix)
|
||||||
|
}
|
||||||
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
// cacheAmdgpuName stores a resolved AMDGPU name in the lookup cache.
|
// cacheAmdgpuName stores a resolved AMDGPU name in the lookup cache.
|
||||||
|
|||||||
Reference in New Issue
Block a user