如何在OSX系统中编程获取GPU温度?

3

我正在尝试在Mac的OSX平台上以编程方式获取GPU温度。

我试图通过Google寻找解决方案,但无法找到。所有我能找到的只有CPU温度和以百分比表示的GPU使用率。

是否有一些API或库可以检索传感器数据?

有人可以告诉我从哪里开始吗? 或者提供一些示例吗?


“Fan Control” Prefpane是开源的(GPL)。源代码已经包含在下载文件中。 - Emmanuel
@Emmanuel,这是针对CPU的(通过SMC很容易获得CPU)。 我需要GPU图形处理器。 - Coldsteel48
抱歉,我需要预约眼科医生。 - Emmanuel
@Emmanuel没关系,谢谢你的帮助! - Coldsteel48
你如何使用Objective-C获取GPU的使用百分比? - ellipticaldoor
2个回答

4

https://developer.nvidia.com/cuda-faq

问:如何从我的应用程序中获取关于GPU温度的信息? 在Microsoft Windows平台上,NVIDIA的NVAPI可以访问GPU温度和许多其他低级GPU功能。

在Linux下,“nvidia-smi”实用程序包含在标准驱动程序安装中,也显示所有已安装设备的GPU温度。

编辑

在进一步研究由基于Linux的系统提供的“nvidia-smi”实用程序时,我发现他们提供了C语言API来获取GPU温度。

https://developer.nvidia.com/nvidia-management-library-nvml https://developer.nvidia.com/nvidia-system-management-interface

https://developer.nvidia.com/sites/default/files/akamai/cuda/files/CUDADownloads/NVML_cuda5/nvml.4.304.55.pdf

从手册中,我发现以下API可用于查找由“nvidia-smi”提供的内容:

7.9.2.8 nvmlReturn_t DECLDIR nvmlUnitGetTemperature (nvmlUnit_t unit, unsigned int type, unsigned
int  temp)
Retrieves the temperature readings for the unit, in degrees C.
For S-class products.
Depending on the product, readings may be available for intake (type=0), exhaust (type=1) and board (type=2).
Parameters:
unit The identifier of the target unit
type The type of reading to take
temp Reference in which to return the intake temperature
Returns:
• NVML_SUCCESS if temp has been populated
• NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
• NVML_ERROR_INVALID_ARGUMENT if unit or type is invalid or temp is NULL
• NVML_ERROR_NOT_SUPPORTED if this is not an S-class product
• NVML_ERROR_UNKNOWN on any unexpected error

希望这对您有用,通过这种方式您可以满足您的需求。 "nvidia-smi" 内部使用上述 API 来查找 GPU 的温度,用户可以通过此方法获取到。这是 NVIDIA 提供的命令行实用程序。


但是,SMC(例如MBP)不应该知道相对调整风扇速度的INFO吗?我确定有一些通用的方法可以从用户范围内访问。 - Coldsteel48
好的,非常感谢!内核模式也可以接受)) - Coldsteel48
@Roma-MT:请查看我编辑过的帖子。希望对你有所帮助。 - Mantosh Kumar
可悲的是,这只适用于NVIDIA,所以基于这个解决方案,我将不得不分别实现ATI和NVIDIA,还有更多的GC制造商? :) - Coldsteel48
@Roma-MT:我认为不可能以通用的方式编写这样低级别的代码,使其适用于所有类型的GPU。你必须依赖硬件供应商来获取这些信息。你可以继续进行 :) - Mantosh Kumar
显示剩余4条评论

0

1
是的,我看到了这个软件,但我正在寻找库或本地API,以使用obj-c或c直接从内核获取这些数据。 (感谢快速回复)我编辑了我的问题以防止进一步的误解。 - Coldsteel48
我看到了,看这个:http://www.daniweb.com/software-development/c/threads/194755/find-cpu-temperature-with-c-code-in-linux - lintr
好的,这是[C]PU温度 :) - Coldsteel48

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接