Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var HasAMDGPU = sync.OnceValue(func() bool { if _, err := os.Stat("/dev/kfd"); err != nil { return false } output := RunRocminfo() if output == "" { return false } if !RocminfoHasDiscreteGPU(output) { return false } if _, err := DetectedVersion(); err != nil { return false } return true })
HasAMDGPU tries to guess if there is an actual discrete AMD GPU with ROCm installed. Integrated (APU) GPUs share system memory and are not suitable for ML workloads, so they are ignored.
It checks for the presence of the /dev/kfd device file (the AMD ROCm compute device), verifies that ROCm drivers are properly installed (`rocminfo` is installed and the drivers with a proper version is found), and then uses `rocminfo` to determine if there is a discrete ROCm GPU.
Functions ¶
func DetectedVersion ¶
DetectedVersion returns the installed ROCm version (e.g. "7.2.4"), read from the ROCm version file, located using InstallDir.
func InstallDir ¶
func InstallDir() string
InstallDir returns the ROCm installation directory. It is used to locate `rocminfo` and the ROCm version file when ROCm is not installed in the default /opt/rocm location.
It checks, in order:
- The ROCM_PATH environment variable, if set to an existing directory.
- The install root inferred from the `rocminfo` binary found in PATH (its parent directory's parent, e.g. <root>/bin/rocminfo -> <root>).
- The default /opt/rocm.
func RocminfoField ¶
RocminfoField returns the value of the given field (e.g. "Name:") within a rocminfo agent block, or "" if not found.
func RocminfoHasDiscreteGPU ¶
RocminfoHasDiscreteGPU parses `rocminfo` output and reports whether at least one AMD GPU agent is a discrete GPU (as opposed to an integrated APU, which reports "Memory Properties: APU").
func RunRocminfo ¶
func RunRocminfo() string
RunRocminfo executes `rocminfo` and returns its output, or "" if it is not available.
Types ¶
This section is empty.