rocm

package
v0.4.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func DetectedVersion() (string, error)

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:

  1. The ROCM_PATH environment variable, if set to an existing directory.
  2. The install root inferred from the `rocminfo` binary found in PATH (its parent directory's parent, e.g. <root>/bin/rocminfo -> <root>).
  3. The default /opt/rocm.

func RocminfoField

func RocminfoField(block, field string) string

RocminfoField returns the value of the given field (e.g. "Name:") within a rocminfo agent block, or "" if not found.

func RocminfoHasDiscreteGPU

func RocminfoHasDiscreteGPU(output string) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL