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.
()
| 661 | // OpenCL ICD loader and is present in most oneAPI base images, so it |
| 662 | // serves as the last-resort fallback. |
| 663 | func 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 |
no test coverage detected