未定义符号:_ZTIN10tensorflow8OpKernelE [英] undefined symbol: _ZTIN10tensorflow8OpKernelE

查看:55
本文介绍了未定义符号:_ZTIN10tensorflow8OpKernelE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚用 pip3 更新了 tensorflow(现在更新到 1.4.1 版).之后我遇到了问题:

我有一个使用 -D _GLIBCXX_USE_CXX11_ABI=0 编译的自定义操作库.该库编译和链接正常.将其导入 tensorflow 给出:

回溯(最近一次调用最后一次):...文件../x.py",第 29 行,位于 <module>lib = tf.load_op_library(_lib_path)文件/home/ilge/.local/lib/python3.5/site-packages/tensorflow/python/framework/load_library.py",第 56 行,在 load_op_librarylib_handle = py_tf.TF_LoadLibrary(library_filename, status)文件/home/ilge/.local/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py",第 473 行,在 __exit__c_api.TF_GetCode(self.status.status))tensorflow.python.framework.errors_impl.NotFoundError:/path/to/mylib.so:未定义符号:_ZTIN10tensorflow8OpKernelE

它似乎无法加载一般的 tensorflow 符号.非常感谢有关我如何调试它的提示.请注意,在更新之前和重新编译之前,一切正常.

解决方案

我在我的 make 文件中分两个不同的步骤编译和链接,当链接不够时只使用正确的链接标志.我还必须将参数 -Wl,--no-as-needed 传递给链接器,因为出于某种原因,gcc 丢弃了最终模块中的库(如 ldd 所示).>

所以我的 Makefile 看起来像这样

TF_CFLAGS:=$(shell python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))')TF_LFLAGS:=$(shell python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))')全部:myop_ops.so%.o: %.ccg++ -fPIC $(TF_CFLAGS) -O2 -std=c++11 -I/usr/local/include -c $<-o $@myop_ops.so: myfile1.o myfile2.o myop_kernel.o myop_ops.og++ -shared -Wl,--no-as-needed $(TF_LFLAGS) -o $@ $^

I just updated tensorflow with pip3 (now to version 1.4.1). After it I am having problems:

I have a custom op library that I compile with -D _GLIBCXX_USE_CXX11_ABI=0. The library compiles and links fine. Importing it into tensorflow gives:

Traceback (most recent call last):
  ...
  File "../x.py", line 29, in <module>
    lib = tf.load_op_library(_lib_path)
  File "/home/ilge/.local/lib/python3.5/site-packages/tensorflow/python/framework/load_library.py", line 56, in load_op_library
    lib_handle = py_tf.TF_LoadLibrary(library_filename, status)
  File "/home/ilge/.local/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: /path/to/mylib.so: undefined symbol: _ZTIN10tensorflow8OpKernelE

It seems it cannot load general tensorflow symbols. Hints on how I could debug it are very appreciated. Note that before the update and before recompiling everything was working.

解决方案

I was compiling and linking in two different steps in my make file, and just using the proper link flags when linking wasn't enough. I also had to pass the argument -Wl,--no-as-needed to the linker, because for some reason gcc was discarding the library in the final module (as shown by ldd).

So my Makefile looks like this

TF_CFLAGS:=$(shell python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))')
TF_LFLAGS:=$(shell python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))')

all: myop_ops.so

%.o: %.cc
    g++ -fPIC $(TF_CFLAGS) -O2 -std=c++11 -I/usr/local/include -c $< -o $@

myop_ops.so: myfile1.o myfile2.o myop_kernel.o myop_ops.o
    g++ -shared -Wl,--no-as-needed $(TF_LFLAGS) -o $@ $^

这篇关于未定义符号:_ZTIN10tensorflow8OpKernelE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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