Read GPU temperature in C# - c#

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

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.

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)

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);
}
}

Related

Xamarin - Deployment on laptop without hardware acceleration support

I'm using MSVS2015Pro with C#/Xamarin.
I have a laptop that doesn't support Hardware Acceleration.
Then I have a question: can I develop for mobiles without having to spend too much time when deploying?.
I could deploy to my real android phone, but I don't know if that's slower than deploying to an AVD. Is it?
What Can I do? I don't wanna do things in a very slow manner.
Do I have to buy a another laptop that supports Hardware Acceleration?
If that's the case, what other requirements I need for that other laptop?
We are running windows 10 with VS 2015 Pro and no hardware acceleration available on the CPU. There is indeed a solid state drive and 16gig ram (The ram doesn’t really assist in running the emulator though. More ram doesn't make the emulator faster. It is rather the processor and or GPU. The ram does assist with running multiple emulator instances.)
Doing both xamarin.iOS and xamarin.android development. I would agree that with hardware acceleration things would be much faster but it is possible to dev on an enterprise level without it. The deployment to emulator (once emulator has started up and is running) vs actual device is much the same. It is indeed faster running the app on an actual device.
I would suggest using actual device to test functionality and the user experience of the app for quick feedback cycles while using the emulator to test different OS versions for compatibility.

WPF giving slow performance on a particular win 8 machine

I have a WPF application utilizing Dotnet framework 4.0 client profile.
The application is running perfectly on any windows 8.0 Dell touch screen machine.
I am trying to run the application on a machine having Intel HD Graphics 4600. The application run is very slow and even the transition effect takes longer.
As I have seen somewhere suggested to try Disabling Hardware Acceleration - I din find any registry key named :
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\DisableHWAcceleration
I have updated the Graphics Driver and all the windows updates are done.
Can anybody please tell me how can I find / change the Hardware Acceleration / Rendering Mode ?
Or is there anything else that need to be checked ?
Update: I have tried setting RenderOption forcefully to SoftwareOnly and result was still the same.
Some more info about the application:
- Its a multi threaded application - doin some checks in the background.
- We are using some of Telerik controls [Telerik UI fro WPF] and version is 2014.1.00331.40
- System details :
Processor : Intel Core(TM) - i5 -4200M CPU #2.50 GHz
RAM : 8GB
Pen and Touch : Full windows touch pints with 10 touch points
Please suggest anything why its working this much slow for this particular machine.

No suitable graphics card is found error in Visual Studio 2010 debug mode

When i try to run my program i get this error:
"No suitable graphics card is found. Could not find a Direct3D device
that supports the XNA Framework Hi-Def profile. Verify that a suitable
graphics device is installed. Make sure your desktop isn't locked, and
that no other application is running in full screen mode. Avoid
running under Remote Desktop or as a Windows service. Check the
display properties to make sure hardware acceleration is set to Full."
I tryied to search: i can't set Rearch profile because i have to use Hi-Def libraries. I tryied to uninstall and install XNA 4.0 and .NET 4.5 but it doesn't work.
What i should do?
My laptop:
Pentium (R) Dual-Core CPU 2.2GHz
RAM: 4GB
Windows 7 Ultimate 32 bit
DirectX 11
Mobile Intel(R) 4 Series Express Chipset Family
Intel Graphics Media Accelerator (GMA) 4500MHD
Your graphics card does not meet the XNA requirements. Why do you have to use Hi-Def? Your DirectX sounds up to date, but those are still very low end cards. Read the exact specifications on Shawn Hargreaves blog for more information.
You can set your XNA project settings in the corresponding tab to target Reach profile, not the HD one. This will probably let you run the app, but beware the performance may be very low.
You may still be able to reference the HD libs and call their methods. Try to solve specific problems you have with that approach instead.
But really get a discrete graphics card if you want high performance and less problems.

Mono for Android - Supported Architecture - Drop x86?

We have a near complete application, and are trying to squeeze under the 50MB download limit for Google Play.
When inspecting our APK to try to find ways to drop our file size, I noticed the lib\x86, lib\armeabi, and lib\armeabi-v7a directories that are described here. They correspond to the 'Supported architecture' option in project options of a Mono for Android project.
If I remove x86, I save around 1.1 MB on our APK size. (This is almost enough to get us under 50MB)
What are the drawbacks for removing x86?
Will my APK still run on x86 devices?
Is there any substantial market share on Google Play for x86 devices?
If it will not work on x86, will Google Play prevent my APK from being installed on x86 devices?
Note that the following answers are for general Android development and do not reflect anything specific to Mono:
What are the drawbacks for removing x86?
Your app will not run on x86 devices. Intel may cry.
Will my APK still run on x86 devices?
No.
Is there any substantial market share on Google Play for x86 devices?
IMHO, not presently. A few handsets were released in 2012 that are Intel-powered (e.g., Motorola RAZR i), and the first generation of Google TV devices were powered by Intel CPUs. But Google TV has switched to ARM, and it will be some time before Intel CPUs make up a substantial portion of the Android device ecosystem (again IMHO).
If it will not work on x86, will Google Play prevent my APK from being installed on x86 devices?
It should. If not, the Play Store has serious issues. While I have a RAZR i sitting here, I don't off the top of my head know an app that uses native code that does not ship with x86, to see if the app in question is indeed filtered out of the Play Store.
are trying to squeeze under the 50MB download limit for Google Play
If a 1.1MB savings "is almost enough to get [you] under 50MB", you are already in trouble. Apps tend to grow, not shrink, over time. If you expect that you will be able to switch to some other distribution architecture (e.g., use APK expansion files) eventually and just need a short-term stop-gap solution, cutting x86 may be OK. But you really need to have a plan for dealing with app size growth that takes you back over the 50MB barrier, and you may be better served addressing that now rather than shipping something and finding yourself painted into a corner as a result.

Trying to detect video card gpu temp but cant add reference nvcpl.dll getting error "could not be added"

I want to detect my video card gpu temperature.
So i wanted to use nvcpl.dll add it as reference to my code.
Im using visual studio 2010 express and windows 7.
I found the file nvcpl.dll in: C:\Windows\System32
But when im trying to add the file as reference im ggeting the error:
" A reference to d:\nvcpl.dll could not be added. Please make make sure that the file is accessible, and that it is a valid assembly or COM component "
I tried also to copy first the file to d:\
I tried examples and codes samples in google.
Cant figure out how to use the dll then.
You can find working source code in C# that gets the GPU temprature (and so much more) from the Open Hardware Monitor project at http://code.google.com/p/open-hardware-monitor/
Open Hardware Monitor
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.
You need to user interop similar to the example code here:
http://www.mp3car.com/coders-corner/107386-vb-net-screenorientation-angle180.html
From the nvidia API docs that I could quickly find (PDF from 2005) it looks like the call you actually need is:
NvCplGetThermalSettings()
Function Prototype
BOOL CDECL NvCplGetThermalSettings
(IN UINT nWindowsMonitorNumber,
OUT DWORD* pdwCoreTemp,
OUT DWORD* pdwAmbientTemp,
OUT DWORD* pdwUpperLimit);
Parameters In UINT nWindowsMonitorNumber -- The display number shown on
the Windows Display Properties->Settings page.
A value of 0 indicates the current primary Windows display device.
DWORD* must be a valid pointer --
pdwCoreTemp -- GPU temperature in degrees Celsius.
pdwAmbientTemp -- Ambient temperature in degrees Celsius.
pdwUpperLimit -- Upper limit of the GPU temperature specification.
Return Values True on success.
False on failure.

Categories

Resources