I am new to linux. My task is to measure the temperature,power and energy consumption. I would like to know is there any sample c program and Makefile available to get these measurements. Also I would like to know is it possible to measure the voltage and current consumption by GPU?? If someone could provide some sample program that would be helpful for me.
nvidia-smi -q will report temperature and power draw (don’t know about voltage). nvidia-smi is an application built on top of the NVML library, which you can also use for your own applications: https://developer.nvidia.com/nvidia-management-library-nvml
The temperature and power measurements are based on sensors integrated into the card and in case of power, measure whole-card power consumption. As these are not carefully calibrated high-precision sensors should not expect the data to be more accurate than +/-5%. You should also not expect instantaneous data, rather data averaged over short time intervals (I can only guess what that interval is, maybe between one second and five seconds?).
For very accurate and instantaneous power data you could use a hardware solution like those used by the more advanced computer hardware review sites.