objective-c - 如何在 OSX 中以编程方式获取 GPU 温度?

标签 objective-c c macos gpu sensors

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

我尝试在 google 上搜索解决方案,但找不到,我只能找到 CPU 温度和 GPU 使用百分比。

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

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

最佳答案

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

Q: How can I get information on GPU temperature from my application? On Microsoft Windows platforms, NVIDIA's NVAPI gives access to GPU temperature and many other low-level GPU functions

Under Linux, the "nvidia-smi" utility, which is included with the standard driver install, also displays GPU temperature for all installed devices.

编辑

在进一步查看基于 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 提供的命令行实用程序。

关于objective-c - 如何在 OSX 中以编程方式获取 GPU 温度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22604939/

相关文章:

c - 运行 minicom 之前 UART 资源暂时不可用

c++ - 找不到Dlib “' dlib/image_processing/frontal_face_detector.h'文件” Xcode C++控制台应用程序

objective-c - 在 dispatch_queue sendComplete 上创建的 RACSubject 没有进入合并信号

iphone - 在 iOS4 中,让 NSTimer 与 NSRunLoop 一起运行会禁用触摸/手势输入

objective-c - Cocoa-Touch:如何在输入验证后更改 View ?

iphone - 在启用弧的项目iOS中添加非弧库

填充数组时崩溃

c - c中的哈希表更新值

objective-c - OS X 辅助功能 API 最小宽度

java - JNA - 获取 OSX 上所有可见的窗口句柄