Search code examples
pythonwindowswmicputemperature

Get sensor values (like Temperature of GPU and CPU) and fan speeds of Windows 10 PC


I've been trying to get a Python script to show temperatures for CPU, GPU and other availabile sensors in my hardware, but I haven't found anything useful.

I tried using WMI to get those values, but my processor is apparently not supported.

The code I used was:

import wmi
w = wmi.WMI(namespace="root\wmi")
temperature_info = w.MSAcpi_ThermalZoneTemperature()[0]
print temperature_info.CurrentTemperature

which I got from another stackoverflow thread, and I get thrown the error Traceback (most recent call last):

  File "C:/Users/Joe/Desktop/test.py", line 3, in <module>
    temperature_info = w.MSAcpi_ThermalZoneTemperature()[0]
  File "C:\Python27\lib\site-packages\wmi.py", line 819, in query
    handle_com_error ()
  File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error
    raise klass (com_error=err)
x_wmi: <x_wmi: Unexpected COM Error (-2147217396, 'OLE error 0x8004100c', None, None)>

which, according to Microsoft Support, means Not Supported (0x8004100C) I have tried running the command-line version of this code in a cmd.exe window ran as an administrator, but I got the same error.

Is there any other way to access CPU and GPU temperatures?

PS: My OS is Windows 10 and my CPU is AMD FX-8350. I am unsure whether my OS or my CPU are at fault for this error.


Solution

  • Here is a way to get your GPU temperature.

    Use nvidia-smi tool.

    This is .exe file present in the location "C:\Program Files\NVIDIA Corporation\NVSMI".

    In the command prompt, just enter:

    cd C:\Program Files\NVIDIA Corporation\NVSMI
    

    then type:

    nvidia-smi
    

    This will display an output like this:

    enter image description here

    You can see the GPU temp! (red underline)

    Coming to the CPU and Fan speed values, Microsoft apparently does not have a built in functionality to at least showcase these values to the user. But you can try 3rd part applications like MSI Afterburner. But Microsoft strictly warns against this as this might affect the performance.