memory

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package memory tracks the NVIDIA per-GPU memory usage.

Index

Constants

View Source
const Name = "accelerator-nvidia-memory"

Name is the ID of the NVIDIA memory component.

View Source
const SubSystem = "accelerator_nvidia_memory"

SubSystem is the Prometheus subsystem name for the NVIDIA memory component.

Variables

This section is empty.

Functions

func New

func New(gpudInstance *components.GPUdInstance) (components.Component, error)

New creates a NVIDIA memory component.

Types

type GetVirtualMemoryFunc added in v0.9.0

type GetVirtualMemoryFunc func(context.Context) (*gopsutilmem.VirtualMemoryStat, error)

GetVirtualMemoryFunc is the function type for getting virtual memory stats. This allows for dependency injection in tests.

type Memory added in v0.9.0

type Memory struct {
	// Represents the GPU UUID.
	UUID string `json:"uuid"`

	// BusID is the GPU bus ID from the nvml API.
	//  e.g., "0000:0f:00.0"
	BusID string `json:"bus_id"`

	TotalBytes     uint64 `json:"total_bytes"`
	TotalHumanized string `json:"total_humanized"`

	ReservedBytes     uint64 `json:"reserved_bytes"`
	ReservedHumanized string `json:"reserved_humanized"`

	UsedBytes     uint64 `json:"used_bytes"`
	UsedHumanized string `json:"used_humanized"`

	FreeBytes     uint64 `json:"free_bytes"`
	FreeHumanized string `json:"free_humanized"`

	UsedPercent string `json:"used_percent"`

	// Supported is true if the memory is supported by the device.
	Supported bool `json:"supported"`

	// IsUnifiedMemory is true when the GPU uses unified memory architecture
	// (shared CPU/GPU memory) and traditional NVML memory APIs are not supported.
	// In this case, system memory values are reported instead.
	// ref. https://docs.nvidia.com/dgx/dgx-spark/known-issues.html
	IsUnifiedMemory bool `json:"is_unified_memory"`
}

Memory reports the memory usage and thresholds for a device.

func GetMemory added in v0.9.0

func GetMemory(uuid string, dev device.Device, productName string, getVirtualMemoryFunc GetVirtualMemoryFunc) (Memory, error)

GetMemory returns the memory statistics for a device.

func (Memory) GetUsedPercent added in v0.9.0

func (mem Memory) GetUsedPercent() (float64, error)

GetUsedPercent returns the used memory percentage.

Jump to

Keyboard shortcuts

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