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" VendorIntel = "intel" 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 | intel
Name string `json:"name"`
State string `json:"state"` // ok | reserved | asleep | unreadable
Load *float64 `json:"load,omitempty"` // percent
Load3D *float64 `json:"load_3d,omitempty"` // percent, 3D/compute engines
LoadVideo *float64 `json:"load_video,omitempty"` // percent, video engines
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, query string) ([]byte, error) // nil -> nvidia-smi from the PATH; query is the whole --query-gpu=... argument; 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
EventDir string // "" -> /sys/bus/event_source/devices
OpenCounter OpenCounter // nil -> openPerf
}
type Counter ¶ added in v0.4.154
Counter is one opened perf counter, in nanoseconds of engine busy time.
type OpenCounter ¶ added in v0.4.154
OpenCounter opens a perf counter of the given event source type on one cpu.
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.