python ctypes和nvapi帮助 [英] help with python ctypes and nvapi

查看:232
本文介绍了python ctypes和nvapi帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的最终目标是查询NVAPI的gpu使用情况和python中的其他统计信息。参见 http://developer.nvidia.com/nvapi

My end goal is to query NVAPI for gpu usage and other statistics in python. See http://developer.nvidia.com/nvapi

from ctypes import WinDLL
nvapi = WinDLL("nvapi.dll")
print nvapi# <WinDLL 'nvapi.dll', handle 718a0000 at 27c0050>
print nvapi.nvapi_QueryInterface# <_FuncPtr object at 0x026D8E40>
print nvapi.nvapi_QueryInterface()# returns 0
print nvapi.NvAPI_Initialize# AttributeError: function 'NvAPI_Initialize' not found
print nvapi.NvAPI_SYS_GetChipSetInfo# AttributeError: function 'NvAPI_SYS_GetChipSetInfo' not found

这里是可从上面的链接下载的头文件的副本: http://paste.pound-python.org/show/7337/

Here is a copy of the header file available for download from the link above: http://paste.pound-python.org/show/7337/

在这一点上,我只是想使自己熟悉api ...所以我在做什么错?我不知道如何调用头文件中列出的任何函数。

At this point, I am just trying to familiarize myself with the api... so what am I doing wrong? I can't figure out how to call any of the functions listed in the header file.

推荐答案

从您的评论中摘录: / p>

Taken from your comment:


NvAPI_Initialize调用仍然失败。
表示找不到该函数。

NvAPI_Initialize call still fails. saying the function is not found.

NvAPI_Initialize 从动态库nvapi.dll中导出。它是NVIDIA SDK附带的静态库nvapi.lib中包含的符号,因此也难怪您无法使用Python进行调用。

NvAPI_Initialize is not exported from the dynamic library nvapi.dll. It is a symbol contained in nvapi.lib, the static library shipped with the NVIDIA SDK, thus it's no wonder you are unable to call it using Python.

老实说,最简单的方法是用C创建一个小的包装DLL,静态链接到nvapi.lib并向Python公开一个友好的界面。

Honestly, the easiest route here is to create a small wrapper DLL in C, statically linking to nvapi.lib and exposing a friendly interface to Python.

这篇关于python ctypes和nvapi帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆