host

package
v2.0.0-beta.7 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 14 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

Overview

Package host reads the facts a snapshot depends on from the machine: the GPUs (NVML), their topology, the driver and kernel, and holds an exclusive lease on the GPUs a run uses.

Index

Constants

View Source
const Timeout = 30 * time.Second

Timeout bounds one query: a GPU that fell off the bus can block NVML for minutes, and the caller should hear about it.

Variables

View Source
var Open = openNVML

Open starts an NVML session; tests replace it with a fake.

Functions

func Busy

func Busy(ctx context.Context, gpus []GPU) (int, error)

Busy counts compute processes on the GPUs.

func CPUFlags

func CPUFlags() []string

CPUFlags are the first CPU's feature flags, sorted: a restored process may use any instruction the donor's CPU had.

func Describe

func Describe(gpus []GPU) string

Describe summarizes GPUs by model: "8× NVIDIA H100 80GB HBM3".

func IOUringDisabled

func IOUringDisabled() (int, error)

IOUringDisabled is kernel.io_uring_disabled; CRIU cannot dump io_uring, so a snapshot needs 2.

func Kernel

func Kernel() string

Kernel is uname -r.

func Leased

func Leased(dir string, g GPU) bool

Leased reports whether a warmctl run holds the GPU's lease in dir.

func MissingFlags

func MissingFlags(donor, here []string) []string

MissingFlags are the donor's CPU flags this host lacks.

func ParseIndices

func ParseIndices(spec string) ([]int, error)

ParseIndices reads "0-3,6".

func Processes

func Processes(ctx context.Context) (map[string]int, error)

Processes counts the compute processes on each GPU, by UUID.

func Topology

func Topology(ctx context.Context, gpus []GPU) (string, string, error)

Topology is the class of the links between the GPUs (nvlink, pcie or single) and, for the record, a digest of the host's link matrix.

func TopologyClass

func TopologyClass(m LinkMatrix, gpus []GPU) string

TopologyClass is nvlink when every pair of the selected GPUs is joined by NVLink, pcie otherwise; a single GPU is "single".

Types

type GPU

type GPU struct {
	Index     int    `json:"index"`
	UUID      string `json:"uuid"`
	Name      string `json:"name"`
	PCIBusID  string `json:"pci_bus_id"`
	MemoryMiB int64  `json:"memory_mib"`
	Driver    string `json:"driver"`
}

GPU is one device as NVML reports it.

func Inventory

func Inventory(ctx context.Context) ([]GPU, error)

Inventory lists every GPU of the host.

func Pick

func Pick(all []GPU, n int, name string, procs map[string]int, locks string) ([]GPU, error)

Pick chooses n GPUs named name, in PCI order, that run no compute process (procs, from Processes) and that no warmctl run leases in locks.

func Select

func Select(all []GPU, spec string) ([]GPU, error)

Select picks GPUs by index list ("0-3,6") or all when spec is empty, in PCI bus order: the order CUDA gives ranks with CUDA_DEVICE_ORDER=PCI_BUS_ID.

type Lease

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

Lease holds an exclusive flock per GPU for the life of a run.

func Acquire

func Acquire(dir string, gpus []GPU) (*Lease, error)

Acquire locks <dir>/gpu-<uuid>.lock for every GPU without waiting.

func (*Lease) Release

func (l *Lease) Release()

Release drops the locks.

type LinkMatrix

type LinkMatrix [][]string

LinkMatrix is how every pair of the host's GPUs is linked: X on the diagonal, NV for NVLink, else the PCIe path.

func (LinkMatrix) String

func (m LinkMatrix) String() string

String renders the matrix as nvidia-smi topo -m lays it out.

type Session

type Session interface {
	Driver() (string, error)
	Count() (int, error)
	// GPU is device i's UUID, name, PCI bus ID as NVML prints it and total
	// memory; Index and Driver are left to the caller.
	GPU(i int) (GPU, error)
	// Processes counts the compute processes on device i.
	Processes(i int) (int, error)
	// NVLink reports whether devices i and j reach each other over NVLink.
	NVLink(i, j int) (bool, error)
	// Path is the closest PCIe ancestor of devices i and j in nvidia-smi
	// topo -m's terms: PIX, PXB, PHB, NODE or SYS.
	Path(i, j int) (string, error)
	Close() error
}

Session is an open NVML session. Devices are numbered in NVML's order, which is nvidia-smi's index.

Jump to

Keyboard shortcuts

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