openhardwaremonitor只获得GPU temp

时间:2017-10-26 08:07:02

标签: c# openhardwaremonitor

我正试图从c#项目中获取我的(nvidia)GPU温度读数。已经有了一个解决方案,使用openhardwaremonitor dll文件。

这是我的代码:

using OpenHardwareMonitor.Hardware;

...

Computer myComputer = new Computer();
myComputer.GPUEnabled = true;
myComputer.Open();

foreach (var hardwareItem in myComputer.Hardware)
{
    if (hardwareItem.HardwareType == HardwareType.GpuNvidia)
    {     
       foreach (var sensor in hardwareItem.Sensors)
       {
           Console.WriteLine(sensor.Identifier.ToString() + ":" + sensor.Value.ToString());
       }                   
    }
}

这导致以下输出:

/nvidiagpu/0/clock/0:
/nvidiagpu/0/clock/1:
/nvidiagpu/0/clock/2:
/nvidiagpu/0/load/3:1.324463

这是获取完整硬件报告的代码:

Computer myComputer = new Computer();
myComputer.GPUEnabled = true;
myComputer.Open();
Console.Write(myComputer.GetReport());

这就是我得到的回报:

    Open Hardware Monitor Report

--------------------------------------------------------------------------------

Version: 0.7.1.0

--------------------------------------------------------------------------------

Common Language Runtime: 4.0.30319.42000
Operating System: Microsoft Windows NT 10.0.15063.0
Process Type: 32-Bit

--------------------------------------------------------------------------------

Sensors

|
+- NVIDIA GeForce 840M (/nvidiagpu/0)
| +- GPU Core : (/nvidiagpu/0/clock/0)
| +- GPU Memory : (/nvidiagpu/0/clock/1)
| +- GPU Shader : (/nvidiagpu/0/clock/2)
| +- GPU Memory : 1.32446 1.32446 1.32446 (/nvidiagpu/0/load/3)

--------------------------------------------------------------------------------

Parameters

|
+- NVIDIA GeForce 840M (/nvidiagpu/0)

--------------------------------------------------------------------------------

AMD Display Library

Status: -1

--------------------------------------------------------------------------------

NVAPI

Version: NVidia Complete Version 1.10
Number of GPUs: 1

--------------------------------------------------------------------------------

Nvidia GPU

Name: NVIDIA GeForce 840M
Index: 0
Driver Version: 382.05
Driver Branch: r381_99-3

DeviceID: 0x134110DE
SubSystemID: 0x504217AA
RevisionID: 0xA2
ExtDeviceID: 0x1341

Thermal Settings

Sensor[0].Controller: GPU_INTERNAL
Sensor[0].DefaultMinTemp: 0
Sensor[0].DefaultMaxTemp: 127
Sensor[0].CurrentTemp: 41
Sensor[0].Target: GPU

Clocks

Clock[8]: 405000
Clock[9]: 11
Clock[10]: 277778
Clock[11]: 1
Clock[30]: 810000
Clock[31]: 17
Clock[32]: 737678
Clock[33]: 25
Clock[34]: 793800
Clock[35]: 25
Clock[36]: 648000
Clock[37]: 9
Clock[40]: 324000
Clock[41]: 9
Clock[44]: 108000
Clock[45]: 1
Clock[92]: 405000
Clock[93]: 32
Clock[99]: 277778
Clock[100]: 32
Clock[169]: 810000
Clock[170]: 32
Clock[176]: 737678
Clock[177]: 15
Clock[178]: 91
Clock[183]: 793800
Clock[184]: 15
Clock[185]: 98
Clock[190]: 648000
Clock[191]: 32
Clock[204]: 324000
Clock[205]: 32
Clock[218]: 108000
Clock[219]: 32

Tachometer

Status: NOT_SUPPORTED

P-States

Percentage[0]: 0
Percentage[1]: 0
Percentage[2]: 0
Percentage[3]: 0

Usages

Usage[1]: 1
Usage[3]: 60
Usage[4]: 30
Usage[5]: 1
Usage[7]: 58
Usage[8]: 29
Usage[9]: 1
Usage[11]: 58
Usage[12]: 29
Usage[13]: 1
Usage[15]: 100
Usage[16]: 100

Cooler Settings


Memory Info

Value[0]: 2097152
Value[1]: 2069376
Value[2]: 0
Value[3]: 4150644
Value[4]: 2069376

正如您所看到的那样,温度读数存在,但我找不到以编程方式获取温度的方法。显然我可以解析返回的字符串并获得温度读数,但我觉得这样做真的很糟糕。

很乐意对此有所了解。

1 个答案:

答案 0 :(得分:1)

我认为你已经找到了解决方案。如果没有,那么这是代码。

import os
os.environ['LDFLAGS'] = '-framework CoreFoundation -framework SystemConfiguration'