MCPcopy
hub / github.com/mudler/LocalAI / getVulkanGPUMemory

Function getVulkanGPUMemory

pkg/xsysinfo/gpu.go:981–999  ·  view source on GitHub ↗

getVulkanGPUMemory queries GPUs using vulkaninfo as a fallback. Note: vulkaninfo JSON is a Vulkan Profiles export and does not include VkPhysicalDeviceMemoryProperties, so memory heaps are parsed from text output.

()

Source from the content-addressed store, hash-verified

979// Note: vulkaninfo JSON is a Vulkan Profiles export and does not include
980// VkPhysicalDeviceMemoryProperties, so memory heaps are parsed from text output.
981func getVulkanGPUMemory() []GPUMemoryInfo {
982 if _, err := exec.LookPath("vulkaninfo"); err != nil {
983 return nil
984 }
985
986 cmd := exec.Command("vulkaninfo", "--text")
987
988 var stdout, stderr bytes.Buffer
989 cmd.Stdout = &stdout
990 cmd.Stderr = &stderr
991
992 if err := cmd.Run(); err != nil {
993 xlog.Debug("vulkaninfo failed", "error", err, "stderr", stderr.String())
994 return nil
995 }
996
997 return parseVulkanGPUMemoryText(strings.NewReader(stdout.String()))
998
999}
1000
1001type vulkanGPUTextInfo struct {
1002 index int

Callers 1

GetGPUMemoryUsageFunction · 0.85

Calls 3

parseVulkanGPUMemoryTextFunction · 0.85
StringMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected