【问题标题】:openhardwaremonitor get only GPU tempopenhardwaremonitor 仅获取 GPU 温度
【发布时间】:2018-04-07 12:26:06
【问题描述】:

我正在尝试从 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());

这是我得到的回报:

打开硬件监视器报告 -------------------------------------------------- ------------------------------ 版本:0.7.1.0 -------------------------------------------------- ------------------------------ 公共语言运行时:4.0.30319.42000 操作系统:Microsoft Windows NT 10.0.15063.0 进程类型:32 位 -------------------------------------------------- ------------------------------ 传感器 | +- 英伟达 GeForce 840M (/nvidiagpu/0) | +- GPU 核心:(/nvidiagpu/0/clock/0) | +- GPU 内存:(/nvidiagpu/0/clock/1) | +- GPU 着色器:(/nvidiagpu/0/clock/2) | +- GPU 内存:1.32446 1.32446 1.32446 (/nvidiagpu/0/load/3) -------------------------------------------------- ------------------------------ 参数 | +- 英伟达 GeForce 840M (/nvidiagpu/0) -------------------------------------------------- ------------------------------ AMD 显示库 状态:-1 -------------------------------------------------- ------------------------------ NVAPI 版本:英伟达完整版 1.10 GPU数量:1 -------------------------------------------------- ------------------------------ 英伟达显卡 名称:NVIDIA GeForce 840M 索引:0 驱动程序版本:382.05 驱动器分支:r381_99-3 设备ID:0x134110DE 子系统 ID:0x504217AA 修订 ID:0xA2 分机ID:0x1341 热设置 传感器[0].控制器:GPU_INTERNAL 传感器 [0].DefaultMinTemp: 0 传感器[0].DefaultMaxTemp:127 传感器[0].CurrentTemp:41 传感器[0].目标:GPU 时钟 时钟[8]:405000 时钟[9]:11 时钟[10]:277778 时钟[11]:1 时钟[30]:810000 时钟[31]:17 时钟[32]:737678 时钟[33]:25 时钟[34]:793800 时钟[35]:25 时钟[36]:648000 时钟[37]:9 时钟[40]:324000 时钟[41]:9 时钟[44]:108000 时钟[45]:1 时钟[92]:405000 时钟[93]:32 时钟[99]:277778 时钟[100]:32 时钟[169]:810000 时钟[170]:32 时钟[176]:737678 时钟[177]:15 时钟[178]:91 时钟[183]​​:793800 时钟[184]:15 时钟[185]:98 时钟[190]:648000 时钟[191]:32 时钟[204]:324000 时钟[205]:32 时钟[218]:108000 时钟[219]:32 转速表 状态:NOT_SUPPORTED P状态 百分比[0]:0 百分比[1]:0 百分比[2]:0 百分比[3]:0 用法 用法[1]:1 用法[3]:60 用法[4]:30 用法[5]:1 用法[7]:58 用法[8]:29 用法[9]:1 用法[11]:58 用法[12]:29 用法[13]:1 用法[15]:100 用法[16]:100 冷却器设置 内存信息 值[0]:2097152 值[1]:2069376 值[2]:0 值[3]:4150644 值[4]:2069376

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

很乐意对此有任何见解。

【问题讨论】:

    标签: c# openhardwaremonitor


    【解决方案1】:

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

    foreach (var sensor in hardwareItem.Sensors)
    {
        if (sensor.SensorType == SensorType.Temperature)
        {
            Console.WriteLine(sensor.Value.ToString());
            Console.WriteLine(sensor.Identifier.ToString() + ":" + sensor.Value.ToString());
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-03-29
      • 1970-01-01
      • 2020-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多