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
- Variables
- func Busy(ctx context.Context, gpus []GPU) (int, error)
- func CPUFlags() []string
- func Describe(gpus []GPU) string
- func IOUringDisabled() (int, error)
- func Kernel() string
- func Leased(dir string, g GPU) bool
- func MissingFlags(donor, here []string) []string
- func ParseIndices(spec string) ([]int, error)
- func Processes(ctx context.Context) (map[string]int, error)
- func Topology(ctx context.Context, gpus []GPU) (string, string, error)
- func TopologyClass(m LinkMatrix, gpus []GPU) string
- type GPU
- type Lease
- type LinkMatrix
- type Session
Constants ¶
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 ¶
var Open = openNVML
Open starts an NVML session; tests replace it with a fake.
Functions ¶
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 IOUringDisabled ¶
IOUringDisabled is kernel.io_uring_disabled; CRIU cannot dump io_uring, so a snapshot needs 2.
func MissingFlags ¶
MissingFlags are the donor's CPU flags this host lacks.
func Topology ¶
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.
type Lease ¶
type Lease struct {
// contains filtered or unexported fields
}
Lease holds an exclusive flock per GPU for the life of a run.
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.