nlesc-recruit / cudawrappers

C++ wrapper for the Nvidia C libraries (e.g. CUDA driver, nvrtc, cuFFT etc.)
https://cudawrappers.readthedocs.io/en/latest/
Apache License 2.0
5 stars 5 forks source link

Add nvml::Device::getPower #302

Closed csbnw closed 2 months ago

csbnw commented 2 months ago

Description

Support for nvmlFieldValue_t was added in CUDA 12 and can (amongst other things) be used to query power usage for a CUDA device. In earlier CUDA versions (e.g. CUDA 11.8), it was common to use nvmlDeviceGetPowerUsage, but it is missing from the API. This function has therefore been added to the nvml::Device class as getPower so that one can query power usage even when using older versions of CUDA.

Related issues:

Instructions to review the pull request

csbnw commented 2 months ago

Nice addition, is it worth adding a test for this new functionality?

That is a good idea, a test is added.

Note that the unit of power is not mentioned in cudawrappers. Like for the other wrapped API calls, users should refer to the NVIDIA documentation for details.