Read GPU temperature in C#

8.3k views Asked by At

I want to create a program that monitors my GPU's temperature (AMD ATI HD) and if it goes below say 50C to send me an email.

I know how to send an email - I just have no idea on how to get the temerature :/

Any help would be awesome!

Running Visual Studio - for Windows Forms (or Java works too!)

Andy

3

There are 3 answers

3
Yggsoft Solutions On

Check out the Overdrive API in the AMD Display Library. They have a C# example but you'll have to add the hook to the temperature library yourself.

AMD Display Library

Specifically: ADL2_Overdrive6_Temperature_Get (ADL_CONTEXT_HANDLE context, int iAdapterIndex, int *lpTemperature)

2
David Pilkington On

I I suggest that you have a look at the OpenHardwareMonitor Project over here

The Open Hardware Monitor is a free open source software that monitors temperature sensors, fan speeds, voltages, load and clock speeds of a computer.

The Open Hardware Monitor supports most hardware monitoring chips found on todays mainboards. The CPU temperature can be monitored by reading the core temperature sensors of Intel and AMD processors. The sensors of ATI and Nvidia video cards as well as SMART hard drive temperature can be displayed. The monitored values can be displayed in the main window, in a customizable desktop gadget, or in the system tray. The Open Hardware Monitor software runs on 32-bit and 64-bit Microsoft Windows XP / Vista / 7 and any x86 based Linux operating systems without installation.

They are open source and you should be able to check out their code and have a look there.

0
Truisms Hounds On

For NVIDIA users...

I tried Open Hardware Monitor, and it worked, but sometimes it would get in a state when it was causing high CPU usage while pulling the GPU temperature (this problem would go away if I had it pulling only the CPU temperature).

I ended up using this NuGet package to pull the temperature directly from NVAPI.

https://github.com/falahati/NvAPIWrapper

Some sample code looks like...

PhysicalGPU[] gpus = PhysicalGPU.GetPhysicalGPUs();
foreach (PhysicalGPU gpu in gpus)
{
    Console.WriteLine(gpu.FullName);
    foreach (GPUThermalSensor sensor in gpu.ThermalInformation.ThermalSensors)
    {
        Console.WriteLine(sensor.CurrentTemperature);
    }
}