From 761065dcd4fcf826c3c8da987392039cc4c79e11 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sun, 28 Dec 2025 21:17:48 +0100 Subject: [PATCH] fix(amd-gpu): correctly show total and used vram An example output of `rocm-smi --showproductname --showmeminfo vram --showuniqueid --csv`: ``` device,Unique ID,VRAM Total Memory (B),VRAM Total Used Memory (B),Card Series,Card Model,Card Vendor,Card SKU,Subsystem ID,Device Rev,Node ID,GUID,GFX Version card0,0x9246____________,17163091968,692142080,Navi 21 [Radeon RX 6800/6800 XT / 6900 XT],0x73bf,Advanced Micro Devices Inc. [AMD/ATI],001,0x2406,0xc1,1,45534,gfx1030 card1,N/A,67108864,26079232,Raphael,0x164e,Advanced Micro Devices Inc. [AMD/ATI],RAPHAEL,0x364e,0xc6,2,52156,gfx1036 ``` Total memory is actually showed before the total used memory as can be seen in https://github.com/LostRuins/koboldcpp/issues/1104#issuecomment-2321143507. This PR fixes https://github.com/mudler/LocalAI/issues/7724 Signed-off-by: Ettore Di Giacinto --- pkg/xsysinfo/gpu.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/xsysinfo/gpu.go b/pkg/xsysinfo/gpu.go index 5597a6ae0302..43021aa5c6b1 100644 --- a/pkg/xsysinfo/gpu.go +++ b/pkg/xsysinfo/gpu.go @@ -354,8 +354,8 @@ func getAMDGPUMemory() []GPUMemoryInfo { } // Parse memory values (in bytes or MB depending on rocm-smi version) - usedBytes, _ := strconv.ParseUint(strings.TrimSpace(parts[1]), 10, 64) - totalBytes, _ := strconv.ParseUint(strings.TrimSpace(parts[2]), 10, 64) + usedBytes, _ := strconv.ParseUint(strings.TrimSpace(parts[2]), 10, 64) + totalBytes, _ := strconv.ParseUint(strings.TrimSpace(parts[1]), 10, 64) // If values seem like MB, convert to bytes if totalBytes < 1000000 {