【问题标题】:undefined symbol: clock_gettime with tensorflow on ubuntu14.04未定义的符号:在 ubuntu14.04 上使用 tensorflow 的clock_gettime
【发布时间】:2016-03-02 23:56:04
【问题描述】:

我已经使用 bazel 从源代码安装了 tensorflow。但是当我在 python 中导入 tensorflow 时,就会发生错误。

>>> import tensorflow as tf

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zjuese/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py", line 8, in <module>
    from tensorflow.python import *
  File "/home/zjuese/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 34, in <module>
    from tensorflow.python.client.client_lib import *
  File "/home/zjuese/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/client_lib.py", line 39, in <module> 
    from tensorflow.python.client.session import InteractiveSession
  File "/home/zjuese/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 16, in <module>
    from tensorflow.python import pywrap_tensorflow as tf_session
  File "/home/zjuese/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 26, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/home/zjuese/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 22, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: /home/zjuese/anaconda2/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so: undefined symbol: clock_gettime

我现在该如何解决?

【问题讨论】:

    标签: python ubuntu tensorflow


    【解决方案1】:

    尝试在链接步骤中添加rt 库,就像在这个差异中一样:

    --- a/tensorflow/tensorflow.bzl
    +++ b/tensorflow/tensorflow.bzl
    @@ -284,7 +284,7 @@ _py_wrap_cc = rule(attrs={
    
     def tf_extension_linkopts():
    -  return []  # No extension link opts
    +  return ["-lrt"]
    

    另请参阅github issue

    【讨论】:

    • 非常感谢。我用修改后的 tensorflow.bzl 重建了 tewnsorflow。现在我可以毫无错误地导入 tensorflow。
    • 加一个链接github问题
    • 我们可以通过 --linkopt 指定它来避免修改文件吗?
    猜你喜欢
    • 2020-05-26
    • 2016-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-08
    • 1970-01-01
    相关资源
    最近更新 更多