Rom*_*-MT 2 c macos gpu objective-c sensors
我正在尝试以编程方式在 mac 的 OSX 平台上获取 GPU 温度
我试图用谷歌搜索解决方案,但我找不到,我能找到的只是 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
Run Code Online (Sandbox Code Playgroud)
希望这会很有用,这样您就可以实现您的要求。“nvidia-smi”内部使用上述API来找出用户获取的GPU温度。这是NVIDIA提供的命令行实用程序。