Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EBPF] GPU-monitoring: added nvml lib path config knob #30263

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cmd/system-probe/modules/gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,26 @@ import (
)

var _ module.Module = &GPUMonitoringModule{}
var gpuMonitoringConfigNamespaces = []string{gpu.GPUConfigNS}
var gpuMonitoringConfigNamespaces = []string{gpu.GPUNS}

// GPUMonitoring Factory
var GPUMonitoring = module.Factory{
Name: config.GPUMonitoringModule,
ConfigNamespaces: gpuMonitoringConfigNamespaces,
Fn: func(_ *sysconfigtypes.Config, deps module.FactoryDependencies) (module.Module, error) {

c := gpu.NewConfig()
probeDeps := gpu.ProbeDependencies{
Telemetry: deps.Telemetry,
NvmlLib: nvml.New(),
NvmlLib: nvml.New(nvml.WithLibraryPath(c.NVMLLibraryPath)),
val06 marked this conversation as resolved.
Show resolved Hide resolved
}

ret := probeDeps.NvmlLib.Init()
if ret != nvml.SUCCESS && ret != nvml.ERROR_ALREADY_INITIALIZED {
return nil, fmt.Errorf("unable to initialize NVML library: %v", ret)
}

t, err := gpu.NewProbe(gpu.NewConfig(), probeDeps)
t, err := gpu.NewProbe(c, probeDeps)
if err != nil {
return nil, fmt.Errorf("unable to start GPU monitoring: %w", err)
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/config/setup/system_probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
pngNS = "ping"
tracerouteNS = "traceroute"
discoveryNS = "discovery"
gpuMonitoringNS = "gpu_monitoring"
gpuNS = "gpu_monitoring"
defaultConnsMessageBatchSize = 600

// defaultServiceMonitoringJavaAgentArgs is default arguments that are passing to the injected java USM agent
Expand Down Expand Up @@ -408,7 +408,9 @@ func InitSystemProbeConfig(cfg pkgconfigmodel.Config) {
cfg.BindEnv("fleet_policies_dir")

// GPU monitoring
cfg.BindEnvAndSetDefault(join(gpuMonitoringNS, "enabled"), false)
cfg.BindEnvAndSetDefault(join(gpuNS, "enabled"), false)
cfg.BindEnv(join(gpuNS, "nvml_library_path"))
cfg.BindEnvAndSetDefault(join(gpuNS, "process_scan_interval_seconds"), 5)

initCWSSystemProbeConfig(cfg)
}
Expand Down
20 changes: 14 additions & 6 deletions pkg/gpu/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,34 @@
package gpu

import (
sysconfig "github.com/DataDog/datadog-agent/cmd/system-probe/config"
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
"time"

"github.com/DataDog/datadog-agent/pkg/ebpf"
)

// GPUConfigNS is the namespace for the GPU monitoring probe.
const GPUConfigNS = "gpu_monitoring"
// GPUNS is the namespace for the GPU monitoring probe.
const GPUNS = "gpu_monitoring"

// Config holds the configuration for the GPU monitoring probe.
type Config struct {
*ebpf.Config
ebpf.Config
// ScanTerminatedProcessesInterval is the interval at which the probe scans for terminated processes.
ScanTerminatedProcessesInterval time.Duration
InitialProcessSync bool
// InitialProcessSync indicates whether the probe should sync the process list on startup.
InitialProcessSync bool
// NVMLLibraryPath is the path of the native libnvidia-ml.so library
NVMLLibraryPath string
}

// NewConfig generates a new configuration for the GPU monitoring probe.
func NewConfig() *Config {
spCfg := pkgconfigsetup.SystemProbe()
return &Config{
Config: ebpf.NewConfig(),
ScanTerminatedProcessesInterval: 5 * time.Second,
Config: *ebpf.NewConfig(),
ScanTerminatedProcessesInterval: time.Duration(spCfg.GetInt(sysconfig.FullKeyPath(GPUNS, "process_scan_interval_seconds"))) * time.Second,
InitialProcessSync: true,
NVMLLibraryPath: spCfg.GetString(sysconfig.FullKeyPath(GPUNS, "nvml_library_path")),
}
}
Loading