gpt4 book ai didi

python - PyArrayObject 定义丢失

转载 作者:行者123 更新时间:2023-11-30 17:42:06 24 4
gpt4 key购买 nike

我正在尝试编译一些 C 代码 (CUDA) [1],它依赖于 Numpy 包:

/cuda-convnet-vs-proj/src/util.cu(69): error : identifier "PyArrayObject" is undefined 

我安装了 Anaconda(在 Windows 上),其中包括 Python 2.7 和 Numpy 包。util.cu 包含 header util.cuh,其中包含 Python.h。

我什至不确定这是否是代码中的问题(缺少定义或头文件),或者 Visual Studio 没有在正确的位置查找。

我是初学者,如何解决这个问题?

这是引用 PyArrayObject 的代码:

#include <util.cuh>
using namespace std;

MatrixV* getMatrixV(PyObject* pyList) {
if (pyList == NULL) {
return NULL;
}
MatrixV* vec = new MatrixV();
for (int i = 0; i < PyList_GET_SIZE(pyList); i++) {
vec->push_back(new Matrix((PyArrayObject*)PyList_GET_ITEM(pyList, i)));
}
return vec;
}

并且 util.cuh header 包含以下行:

#include <Python.h>

[1] http://www.asiteof.me/archives/50

最佳答案

通过包含定义 PyArrayObject 的 ndarraytypes.h 来解决。

关于python - PyArrayObject 定义丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20831957/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com