我正在尝试在Mac的OSX平台上以编程方式获取GPU温度。
我试图通过Google寻找解决方案,但无法找到。所有我能找到的只有CPU温度和以百分比表示的GPU使用率。
是否有一些API或库可以检索传感器数据?
有人可以告诉我从哪里开始吗? 或者提供一些示例吗?
我正在尝试在Mac的OSX平台上以编程方式获取GPU温度。
我试图通过Google寻找解决方案,但无法找到。所有我能找到的只有CPU温度和以百分比表示的GPU使用率。
是否有一些API或库可以检索传感器数据?
有人可以告诉我从哪里开始吗? 或者提供一些示例吗?
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
从手册中,我发现以下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 提供的命令行实用程序。
试试这个名为“Magican”的软件,它的图标是一只大象,可以在状态栏中显示CPU和GPU温度,点击后可以查看您启动的进程http://i.stack.imgur.com/ekeW2.png。