1

在尝试在 tensorflow 中将 CRF 实现为 RNN 时,根据此处的说明:https ://github.com/liangy1969/CRF-RNN_Tensorflow ,我在下面遇到了错误。

onur@onur-GE62VR-6RF:~/tf_kodlar/CRF-RNN_Tensorflow-master/src$ python3 setup.py build_ext --inplace

running build_ext

building '_permutohedral' extension

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict
-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security
-Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -I/usr/include/python3.5m -c 
permutohedral_wrap.cxx -o build/temp.linux-x86_64-3.5/permutohedral_wrap.o

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for
C/ObjC but not for C++
permutohedral_wrap.cxx: In function ‘PyObject*
_wrap_PermutohedralLattice_get_enclosing_simplices(PyObject*, PyObject*)’:
permutohedral_wrap.cxx:4056:10: error: invalid conversion from ‘long long 
unsigned int*’ to ‘size_t* {aka long unsigned int*}’ [-fpermissive]

arg2 = (unsigned long long*) array_data(array2);
     ^
permutohedral_wrap.cxx: In function ‘PyObject*
_wrap_PermutohedralLattice_get_blur(PyObject*, PyObject*)’:
permutohedral_wrap.cxx:4166:10: error: invalid conversion from ‘long long 
unsigned int*’ to ‘size_t* {aka long unsigned int*}’ [-fpermissive]
arg2 = (unsigned long long*) array_data(array2);
     ^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

在我上面给出的链接中,liangy1969 已经提供了 permutohedral.py 和 _permutohedral...pyd,但是直接尝试使用它们在这里给出了问题:https ://github.com/liangy1969/CRF-RNN_Tensorflow/issues/1它是得出结论,原因可能是文件是在win64中编译的,每个文件都需要自己构建。但是在构建时我得到了上面的错误。

另外,在 setup.py 中,这个家伙给出了以下声明: include_dirs=['$PYTHON_PATH/Lib/site-packages/numpy/core/include']

我在 site-packages 下找不到我的 python_path 或任何 numpy/core/include 但我在 /usr/local/lib/python3.5/dist-packages 下找到了 numpy/core/include 所以我从 site-包到 dist 包。我不知道这是否正确,不幸的是我还不是 python 或 linux 环境的专家。可能会发生我的一个非常愚蠢的错误,以防万一。

我正在使用 python3(3.5)和 tensorflow r1.3(如果需要)和 ubuntu 16.04。任何人都可以帮忙吗?谢谢。

4

1 回答 1

0

我遇到了同样的问题。我删除了一个“长”类型说明符。所以不是(unsigned long long*)它只是(unsigned long*)

至于 numpy 路径。这是我的 setup.py:

permuto_module = Extension('_permutohedral', sources = ['permutohedral_wrap.cxx', 'permutohedral.cpp'], include_dirs=['/home/hallab/.local/lib/python3.5/site-packages/numpy/core/include'])

我的 numpy 标题在 .local 中,我花了一段时间才找到啊。

于 2019-04-25T14:20:35.030 回答