Get the temperature of GPU

Hello!

I am using Visual Studio 2017 and CUDA 9.1.

Found that the temperature of the GPU can be obtained using “nvapi.h” and “nvml.h”, but if I include “nvapi.h”, I get an error: “I can not open the source file “nvapi.h””. As for “nvml.h”, I can include this library, but as soon as I use the “nvmlInit()” function, I see the error: “reference to an unauthorized external character is unavailable in main function”.

Help me please. I have been trying to solve this for the third day.

You’ll need to learn more about C/C++ programming in VS 2017.

When you include a header file like nvapi.h, you must also tell the compiler where to find that file, using project settings.

Likewise, when you call a function in a header file, you must also link your code against a library that includes that function. Just including the header file is usually not sufficient (excepting template/header libraries, which is not the case for either of these). There are worked examples for both NVML and NVAPI usage if you want to look for them.

Thank you. I will look for.

perhaps simply
/usr/bin/nvidia-smi -a

Bill