Documentation
¶
Overview ¶
Package gpustats reads the usage of graphics cards. A figure the box does not measure is absent (nil), never 0.
Index ¶
Constants ¶
const ( VendorNVIDIA = "nvidia" VendorAMD = "amd" StateOK = "ok" StateReserved = "reserved" StateAsleep = "asleep" StateUnreadable = "unreadable" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Card ¶
type Card struct {
Index int `json:"index"`
Address string `json:"address"` // 0000:08:00.0
Vendor string `json:"vendor"` // nvidia | amd
Name string `json:"name"`
State string `json:"state"` // ok | reserved | asleep | unreadable
Load *float64 `json:"load,omitempty"` // percent
MemoryUsed *float64 `json:"memory_used,omitempty"` // bytes
MemoryTotal *float64 `json:"memory_total,omitempty"` // bytes
Temperature *float64 `json:"temperature,omitempty"` // °C
Power *float64 `json:"power,omitempty"` // watts
}
type Config ¶
type Config struct {
PCIDir string // "" -> /sys/bus/pci/devices
ReservedFile string // "" -> /var/lib/casaos/gpu-reserved
SMI func(ctx context.Context) ([]byte, error) // nil -> nvidia-smi from the PATH; absent from the PATH = no NVIDIA figures
NameOf func(vendor, device string) string // pci.ids; nil -> generic names
Now func() time.Time // nil -> time.Now
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service reads the cards in its own goroutine and keeps the last reading in memory: Latest never waits for a read.
var Default *Service
Default is the service of the running core; nil until wired.