Help us shape the future of Go! Take the 2026 Go Developer Survey

system

package
v2.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AMDGPUSysfsPath = "/sys/class/drm"
)

AMDGPUSysfsPath is the sysfs base used to discover AMD GPUs.

Variables

This section is empty.

Functions

func HasAMDGPU

func HasAMDGPU() bool

HasAMDGPU reports whether a card with mem_info_vram_total exists under AMDGPUSysfsPath.

Types

type GPUMonitor

type GPUMonitor struct {
	// contains filtered or unexported fields
}

GPUMonitor probes for an attached GPU (NVIDIA / AMD / Intel) and reports VRAM usage. Detection is cached for gpuDetectionTTL; once a vendor is detected, subsequent Stats calls invoke the vendor-specific tool directly.

func NewGPUMonitor

func NewGPUMonitor(enabled bool, configuredType string) *GPUMonitor

NewGPUMonitor creates a monitor. enabled gates Stats; when false, Stats returns (nil, nil). configuredType is the user-pinned vendor ("nvidia"|"amd"|"intel"|"auto"|"") — anything else falls back to auto-detection.

func (*GPUMonitor) Enabled

func (m *GPUMonitor) Enabled() bool

Enabled reports whether GPU monitoring is on.

func (*GPUMonitor) Stats

func (m *GPUMonitor) Stats(ctx context.Context) ([]systemtypes.GPUStats, error)

Stats returns per-GPU VRAM stats. Returns (nil, 0, nil) when monitoring is disabled or no GPU is detected; vendor-specific errors are propagated otherwise. Results (including failures) are cached for gpuStatsTTL, so callers may receive stats up to that many seconds old.

Jump to

Keyboard shortcuts

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