Documentation
¶
Overview ¶
Package gpu detects NVIDIA GPUs on a node by querying nvidia-smi and the Docker daemon's registered runtimes. It never shells out to the docker CLI.
Index ¶
Constants ¶
const ( StatusOK = "ok" StatusWarn = "warn" StatusFail = "fail" )
Finding statuses, matching the doctor report's vocabulary.
const ( AttachCDI = "cdi" AttachLegacy = "legacy" AttachNone = "none" )
Attach modes a host can use for GPU containers.
const ( // CDIGenerateCommand writes the NVIDIA CDI spec that CDI attach needs. CDIGenerateCommand = "sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml" // CDIEnableHint is the remedy when a spec exists but Docker lists no CDI devices. CDIEnableHint = `` /* 147-byte string literal not displayed */ )
const DriverHint = "No NVIDIA driver detected. On Ubuntu run ubuntu-drivers install (or apt-get install nvidia-driver-XXX), then reboot."
DriverHint is the operator-facing remedy when no NVIDIA driver answers.
const InstallCommand = "" /* 135-byte string literal not displayed */
InstallCommand is the copy-pasteable fix for a missing nvidia runtime, assuming NVIDIA's apt repository is already configured.
const InstallHint = "" /* 209-byte string literal not displayed */
InstallHint is the operator-facing remedy when GPUs exist but Docker has no nvidia runtime.
Variables ¶
var ( ErrNoGPU = errors.New("node reports no NVIDIA GPU") ErrRuntimeMissing = errors.New("the nvidia container runtime is not registered with Docker on the node") ErrUnknownDevice = errors.New("GPU device not present on the node") ErrDeviceTaken = errors.New("GPU device already reserved") ErrInsufficient = errors.New("not enough free GPUs") )
Sentinel reasons a claim does not fit a node.
Functions ¶
Types ¶
type Claim ¶
Claim is one workload's GPU reservation. With no DeviceIDs, Count <= 0 means every GPU on the node, matching how Docker's request is built.
type Device ¶
type Device struct {
Index int
UUID string
Name string
VRAMTotalMiB int64
VRAMUsedMiB int64
UtilizationPercent int
}
Device is one GPU as reported by nvidia-smi.
type DockerFacts ¶
type DockerFacts interface {
RuntimeNames(ctx context.Context) ([]string, error)
CDIDevices(ctx context.Context) ([]string, error)
}
DockerFacts is what the diagnosis asks the Docker daemon.
type Finding ¶
type Finding struct {
Code string `json:"code"`
Name string `json:"name"`
Status string `json:"status"`
Message string `json:"message"`
Fix string `json:"fix,omitempty"`
}
Finding is one diagnosed aspect of a host's GPU setup.
type HostDiagnosis ¶
type HostDiagnosis struct {
Info Info
ToolkitVersion string
CDISpecFiles []string
CDIDevices []string
Attach string
Findings []Finding
}
HostDiagnosis is the detailed GPU picture of one host.
func DiagnoseHost ¶
func DiagnoseHost(ctx context.Context, r Runner, d DockerFacts, glob func(pattern string) []string) HostDiagnosis
DiagnoseHost inspects this host's GPU stack: driver, per-GPU memory, the NVIDIA container toolkit, CDI specs and how Docker can attach GPUs. glob may be nil to use the real filesystem.
type Info ¶
Info is a node's GPU capability snapshot.
func Detect ¶
func Detect(ctx context.Context, r Runner, rl RuntimeLister) Info
Detect returns the node's GPU snapshot. A missing nvidia-smi or a failing query means no GPU, not an error: most nodes have none.
func (Info) Hint ¶
Hint returns remediation text when the node has a GPU problem, or empty when there is nothing to fix (including nodes with no GPU).
func (Info) TotalVRAMMiB ¶
TotalVRAMMiB sums VRAM across devices.
type Ledger ¶
type Ledger struct {
// contains filtered or unexported fields
}
Ledger tracks which GPUs of one node are reserved. Docker does not enforce exclusivity, so this is scheduling accounting, not isolation.
type RuntimeLister ¶
RuntimeLister reports the OCI runtimes registered with Docker.