
本文共 1523 字,大约阅读时间需要 5 分钟。
Linux下最相似的方法是使用NVCtrl API是什么nvidia-settings,Linux的NVIDIA控制面板应用程序,提供。
如何下载nvidia-settings源码包在linux驱动程序发行说明中有记录。具体而言,您可以找到特定驱动程序版本的各种软件包here
选择一个与您的驱动程序版本最接近的软件包。
下载并解压缩nvidia-settings源代码后,您会发现一个samples目录。在那个目录中是一个示例程序,它有你想要的必要框架。具体来看,在nv-control-targets.c。在该文件下面的函数会做你想要什么:
/* Connected Display Devices on GPU */
ret = XNVCTRLQueryTargetAttribute(dpy,
NV_CTRL_TARGET_TYPE_GPU,
gpu, // target_id
0, // display_mask
NV_CTRL_CONNECTED_DISPLAYS,
&display_devices);
if (!ret) {
fprintf(stderr, "Failed to query connected displays\n");
return 1;
}
printf(" Display Device Mask (Connected) : 0x%08x\n",
display_devices);
注意,有一些准备/设置功能,在那个节目(nv-control-targets.c),其将需要以及执行的最高要求。
在NVML(nvidia-smi基于NVML)中还有一个函数(显示模式),它会告诉您GPU是否托管显示器,但我不确定它是否给出了粒度你要。
事实上,在重新阅读您的问题时,NVML显示模式可能足以满足您的需求。参考API文档here,p46:
7.10.2.10 nvmlReturn_t DECLDIR nvmlDeviceGetDisplayMode (nvmlDevice_t device, nvmlEnableState_t
display)
Retrieves the display mode for the device.
For Tesla ™and Quadro ®products from the Fermi and Kepler families.
This method indicates whether a physical display is currently connected to the device.
See nvmlEnableState_t for details on allowed modes.
Parameters:
device The identifier of the target device
display Reference in which to return the display mode
Returns:
• NVML_SUCCESS if display has been set
• NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
• NVML_ERROR_INVALID_ARGUMENT if device is invalid or display is NULL
• NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
转载地址:https://blog.csdn.net/weixin_33595317/article/details/116849430 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
关于作者
