MCPcopy Index your code
hub / github.com/mudler/LocalAI / getIntelGPUMemory

Function getIntelGPUMemory

pkg/xsysinfo/gpu.go:663–683  ·  view source on GitHub ↗

getIntelGPUMemory queries Intel GPUs via xpu-smi, intel_gpu_top, or clinfo (in that order). xpu-smi is the canonical Intel tool but requires the separate xpumanager package; clinfo ships with the OpenCL ICD loader and is present in most oneAPI base images, so it serves as the last-resort fallback.

()

Source from the content-addressed store, hash-verified

661// OpenCL ICD loader and is present in most oneAPI base images, so it
662// serves as the last-resort fallback.
663func getIntelGPUMemory() []GPUMemoryInfo {
664 if gpus := getIntelXPUSMI(); len(gpus) > 0 {
665 return gpus
666 }
667 if gpus := getIntelGPUTop(); len(gpus) > 0 {
668 return gpus
669 }
670 // clinfo enumerates every OpenCL platform, so guard the
671 // subprocess with the cached ghw GPU list: non-Intel hosts skip
672 // it entirely.
673 if !hasGHWVendor(VendorIntel) {
674 return nil
675 }
676 var out []GPUMemoryInfo
677 for _, g := range getCLInfoGPUMemory() {
678 if g.Vendor == VendorIntel {
679 out = append(out, g)
680 }
681 }
682 return out
683}
684
685// hasGHWVendor reports whether ghw observed any GPU whose vendor name
686// matches (case-insensitive substring). Uses the package-level cache

Callers 1

GetGPUMemoryUsageFunction · 0.85

Calls 4

getIntelXPUSMIFunction · 0.85
getIntelGPUTopFunction · 0.85
hasGHWVendorFunction · 0.85
getCLInfoGPUMemoryFunction · 0.85

Tested by

no test coverage detected