Documentation
¶
Overview ¶
Package systeminfo provides the canonical SystemInfo hardware, library, clock, power, and host contention record shared across cudadiag, cudacapture, cudaflightrecorder, cuptiactivity, cudaprof, and servebench.
Index ¶
- Constants
- Variables
- func EvaluateHostCPUOutput(psOutput, engineName string, selfPID int, unifiedMem bool) (topProcs []string, contended bool)
- func FinishCaptureSystemInfo(ctx context.Context, info *SystemInfo, opts Options)
- func IsUnifiedMemoryGPU(gpuName, smArch string) bool
- func MajorMinor(v string) string
- func MergeTopCPUProcs(existing, latest []string) []string
- func ParseNVCCVersionOutput(output string) string
- func ParseProcMapsCUDALibs(mapsContent string, resolveSymlink func(string) string) map[string]string
- func ProbeNVCCVersion(ctx context.Context) string
- func ProbeProcessCUDALibs(pids ...int) map[string]string
- func ReadLoadAvg() ([3]float64, error)
- func ResolveGitState(repoDir string) (commit string, dirty bool)
- func SampleHostCPU(ctx context.Context, engineName string, unifiedMem bool) (topProcs []string, contended bool)
- func SharedObjectVersion(filename string) (base, version string)
- type Options
- type SystemInfo
Constants ¶
const ContentionCPUThresholdPct = 50.0
ContentionCPUThresholdPct is the single-process CPU utilization threshold (>= 50%) that flags host CPU contention on unified-memory architectures (such as GB10 and GH200) where host CPU bandwidth contends with GPU memory.
Variables ¶
var ErrIncompleteSystemInfo = errors.New("cudadiag: incomplete system info")
ErrIncompleteSystemInfo is returned when required hardware, clock, power, or CUDA library provenance fields are missing from a SystemInfo record.
Functions ¶
func EvaluateHostCPUOutput ¶
func EvaluateHostCPUOutput(psOutput, engineName string, selfPID int, unifiedMem bool) (topProcs []string, contended bool)
EvaluateHostCPUOutput parses `ps -eo pid,pcpu,comm` output, returning top non-engine processes (>= 10% CPU, up to 5) and whether host CPU contention (>= 50% CPU by a non-engine process on a unified-memory architecture) occurred.
func FinishCaptureSystemInfo ¶
func FinishCaptureSystemInfo(ctx context.Context, info *SystemInfo, opts Options)
FinishCaptureSystemInfo updates the end-of-run clocks, power, throttle bitmask, host load average, and host CPU contention fields on an existing SystemInfo record.
func IsUnifiedMemoryGPU ¶
IsUnifiedMemoryGPU reports whether the given GPU model name or SM architecture represents a coherent unified-memory SoC (such as NVIDIA GB10, GB200, or GH200) where host CPU memory traffic shares package/memory bandwidth with the GPU.
func MajorMinor ¶
MajorMinor returns the major.minor prefix of a dotted version string. For example, MajorMinor("13.0.88") returns "13.0".
func MergeTopCPUProcs ¶
MergeTopCPUProcs merges two slices of "<comm>(pid=<pid>):<pct>%" strings, keeping the highest observed CPU percentage per process.
func ParseNVCCVersionOutput ¶
ParseNVCCVersionOutput extracts the version string from `nvcc --version` output.
func ParseProcMapsCUDALibs ¶
func ParseProcMapsCUDALibs(mapsContent string, resolveSymlink func(string) string) map[string]string
ParseProcMapsCUDALibs extracts loaded CUDA/NVIDIA shared library versions from the text of a Linux /proc/<pid>/maps file. The optional resolveSymlink callback resolves symlinks (such as libcublasLt.so.12 -> libcublasLt.so.12.8.4.1) to their full versioned filenames.
func ProbeNVCCVersion ¶
ProbeNVCCVersion runs nvcc --version (searching PATH and standard CUDA toolkit locations) and returns the compiler version string (for example "12.8.93").
func ProbeProcessCUDALibs ¶
ProbeProcessCUDALibs scans /proc/<pid>/maps for the given PIDs and returns a map of loaded CUDA/NVIDIA shared library base names (such as "libcublasLt.so", "libnvrtc.so", "libcudart.so", "libcuda.so") to their resolved version strings.
func ReadLoadAvg ¶
ReadLoadAvg reads the 1-, 5-, and 15-minute host CPU load averages with hoststate.Sample.
func ResolveGitState ¶
ResolveGitState returns the VCS commit hash and dirty flag from embedded Go build info or by querying git in repoDir (or the current working directory).
func SampleHostCPU ¶
func SampleHostCPU(ctx context.Context, engineName string, unifiedMem bool) (topProcs []string, contended bool)
SampleHostCPU inspects running host processes via ps and returns the top non-engine CPU processes ("<comm>(pid=<pid>):<pct>%") and whether any non-engine process uses >= 50% CPU on a unified-memory GPU.
func SharedObjectVersion ¶
SharedObjectVersion splits a versioned shared object filename such as "libcublasLt.so.13.1.0.3" into ("libcublasLt.so", "13.1.0.3").
Types ¶
type Options ¶
type Options struct {
// GPUIndex selects the device index to query. Negative values default to 0.
GPUIndex int
// EngineName identifies the workload or profiling engine (for example
// "cudaprof", "servebench", "sglang", "vllm"). Processes matching EngineName
// are excluded when evaluating non-engine host CPU contention.
EngineName string
// PIDs lists target process IDs whose /proc/<pid>/maps should be inspected
// first for loaded CUDA shared libraries. The current process PID is always
// included as a fallback.
PIDs []int
// RepoDir is an optional directory used to resolve GitCommit and GitDirty
// when build info does not embed VCS metadata.
RepoDir string
}
Options configures live SystemInfo collection.
type SystemInfo ¶
type SystemInfo struct {
Host string `json:"host"`
OS string `json:"os"`
Arch string `json:"arch"`
GPUIndex int `json:"gpu_index"`
GPUName string `json:"gpu_name"`
UUID string `json:"uuid"`
SMArch string `json:"sm_arch"`
SMCount int `json:"sm_count"`
L2CacheBytes int64 `json:"l2_cache_bytes"`
DriverVersion string `json:"driver_version"`
CUDADriverVersion string `json:"cuda_driver_version"`
CUDARuntimeVersion string `json:"cuda_runtime_version"`
CUDAToolkitVersion string `json:"cuda_toolkit_version"`
CuBLASLtVersion string `json:"cublaslt_version"`
NVRTCVersion string `json:"nvrtc_version"`
CUDALibs map[string]string `json:"cuda_libs,omitempty"`
NVCCVersion string `json:"nvcc_version"`
StartSMClockMHz uint32 `json:"start_sm_clock_mhz"`
EndSMClockMHz uint32 `json:"end_sm_clock_mhz"`
MaxSMClockMHz uint32 `json:"max_sm_clock_mhz"`
StartPowerMW uint32 `json:"start_power_mw"`
EndPowerMW uint32 `json:"end_power_mw"`
PowerLimitMW uint32 `json:"power_limit_mw"`
ThrottleReasonsBitmask uint64 `json:"throttle_reasons_bitmask"`
HostLoadAvgStart [3]float64 `json:"host_load_avg_start"`
HostLoadAvgEnd [3]float64 `json:"host_load_avg_end"`
// HostLoadAvgError says why a host load average could not be read;
// the zeros beside it are then unknown, not an idle host.
HostLoadAvgError string `json:"host_load_avg_error,omitempty"`
HostTopCPUProcs []string `json:"host_top_cpu_procs,omitempty"`
HostCPUContended bool `json:"host_cpu_contended"`
EngineName string `json:"engine_name"`
GitCommit string `json:"git_commit"`
GitDirty bool `json:"git_dirty"`
}
SystemInfo is the single canonical hardware, library, clock/power, and host contention record embedded in cudaprof captures, servebench results, cudaflightrecorder bundles, and cuptiactivity relational table exports.
func CaptureSystemInfo ¶
func CaptureSystemInfo(ctx context.Context, opts Options) (*SystemInfo, error)
CaptureSystemInfo queries live host and GPU state to construct a populated SystemInfo record.
func StartCaptureSystemInfo ¶
func StartCaptureSystemInfo(ctx context.Context, opts Options) (*SystemInfo, error)
StartCaptureSystemInfo records the start-of-run SystemInfo snapshot (device identity, driver/library versions, start clocks/power, and start host load).
func (*SystemInfo) Validate ¶
func (s *SystemInfo) Validate() error
Validate checks that all required hardware, clock, power, library, and build provenance fields are populated, returning an error wrapping ErrIncompleteSystemInfo if any required field is missing.