memory

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 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"
View Source
const SubSystem = "accelerator_nvidia_memory"

Variables

This section is empty.

Functions

func New

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

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"`
}

func GetMemory added in v0.9.0

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

func (Memory) GetUsedPercent added in v0.9.0

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

Jump to

Keyboard shortcuts

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