fatal error: nsync_cv.h: No such file or directory

从TF1.3升级到TF1.4之后,自己写的op也要重新编译

TF_INC=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
TF_LIB=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')

i=$1
o=${i/.cc/.so}

g++ -std=c++11 -shared $i -o $o -fPIC -I $TF_INC  -D_GLIBCXX_USE_CXX11_ABI=0 -L $TF_LIB

github上有人回答:
I was able to fix the issue by adding /usr/local/lib/python3.6/site-packages/tensorflow/include/external/nsync/public to my header search path (TF v1.4)
https://github.com/tensorflow/tensorflow/issues/12482

所以编译时增加一个include目录即可,具体如下:

TF_INC=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
TF_LIB=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')

i=$1
o=${i/.cc/.so}

g++ -std=c++11 -shared $i -o $o -fPIC -I $TF_INC -I /usr/local/lib/python2.7/dist-packages/tensorflow/include/external/nsync/public/ -D_GLIBCXX_USE_CXX11_ABI=0 -L $TF_LIB

但是紧接着调用.so库是还会报错。
https://github.com/tensorflow/tensorflow/issues/13607

Then while trying to load the .so file I run into
tensorflow.python.framework.errors_impl.NotFoundError: ./max_align_bytes_op.so: undefined symbol: _ZTIN10tensorflow8OpKernelE

最终根据issue找到了更新版本的官方文档:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/docs_src/extend/adding_an_op.md

TF_INC=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
TF_LIB=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')

i=$1
o=${i/.cc/.so}


g++ -std=c++11 -shared $i -o $o  -fPIC -I$TF_INC -I$TF_INC/external/nsync/public -L$TF_LIB -ltensorflow_framework -O2  -D_GLIBCXX_USE_CXX11_ABI=0
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值