hostcapacity

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package hostcapacity gives the CLI a best-effort, pre-install estimate of how much memory a curated model would have to fit in on this machine.

It is deliberately coarse and deliberately not modeld: modeld's real capacity planning (modeld/capacity) resolves a model's actual KV profile against the live device it opened a session on, through a CGO-linked backend (ggml / OpenVINO device enumeration). None of that exists before modeld is even installed - exactly when `contenox setup` and `contenox model registry-list` need to say something useful about fit.

Detect returns the best signal available without linking modeld: an NVIDIA GPU's total/free VRAM via a best-effort `nvidia-smi` shell probe (pure Go, no CGO - this is the CLI, not modeld, so the project's no-subprocess-in-modeld rule does not apply here), falling back to system RAM via gopsutil when no such GPU is found or the probe fails. Detect never fabricates a number: Known is false when neither source could be read, and callers must not display fit information in that case.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Budget

type Budget struct {
	Kind       string // "gpu" | "system"
	Label      string // e.g. "NVIDIA GeForce GTX 1660" or "system RAM"
	TotalBytes int64
	FreeBytes  int64
	// Known is false when detection found nothing usable. Callers must treat
	// this as "no fit signal", never as "nothing fits".
	Known bool
}

Budget is the best-effort memory pool a curated model's estimated resident footprint (modelregistry.ModelDescriptor.EstimatedResidentBytes) is compared against.

func Detect

func Detect(ctx context.Context) Budget

Detect resolves the best available memory budget using the real nvidia-smi + gopsutil sources: an NVIDIA GPU when nvidia-smi is present and answers, else system RAM, else an unknown (Known: false) budget.

type Detector

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

Detector resolves the best-effort host memory budget. Construct with New; run and systemRAM are injectable for tests.

func New

func New() *Detector

New returns a Detector using the real nvidia-smi + gopsutil sources.

func (*Detector) Detect

func (d *Detector) Detect(ctx context.Context) Budget

Detect resolves the best available memory budget for this Detector.

Jump to

Keyboard shortcuts

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