NVIDIA / go-dcgm

Golang bindings for Nvidia Datacenter GPU Manager (DCGM)
Apache License 2.0
96 stars 27 forks source link

provide more flexible WatchPidFields API #59

Open rootfs opened 9 months ago

rootfs commented 9 months ago

I am using go-dcgm to estimate power consumption of processes running in MIG device. The current pid watch function watchPidFields doesn't track the MIG devices.

Would it be possible to create yet another API to pass group.handle directly? So caller can create device groups that consist MIG and call the dcgm API to watch pid.

A hypothetical prototype is like the following:

func WatchPidFieldsWithGroup(updateFreq, maxKeepAge time.Duration, maxKeepSamples int, groupId GroupHandle) error {
    result := C.dcgmWatchPidFields(handle.handle, groupId.handle, C.longlong(updateFreq.Microseconds()), C.double(maxKeepAge.Seconds()), C.int(maxKeepSamples))
    if err := errorString(result); err != nil {
        return &DcgmError{msg: C.GoString(C.errorString(result)), Code: result}
    }
    _ = UpdateAllFields()
    return nil
}
nvvfedorov commented 9 months ago

@rootfs , Thank you for submitting the issue. We accept PRs if you have a good solution.

rootfs commented 9 months ago

@nvvfedorov that sounds good, i'll test it locally and if this works, i'll submit a PR, thanks