首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Tensorflow skylake-avx512 512编译自缺少的源__cpu_model符号

Tensorflow skylake-avx512 512编译自缺少的源__cpu_model符号
EN

Stack Overflow用户
提问于 2019-10-05 01:31:44
回答 1查看 339关注 0票数 0

我正在用skylake- am 512编译tensorflow,如下所示,我的python是这样构建的:

代码语言:javascript
复制
git clone https://github.com/python/cpython.git && cd cpython && git checkout 2.7
CXX="/usr/bin/g++" CXXFLAGS="-O3 -mtune=skylake-avx512 -march=skylake-avx512" CFLAGS="-O3 -mtune=skylake-avx512 -march=skylake-avx512" ./configure  \
            --enable-optimizations  \
            --with-lto \
            --enable-unicode=ucs4  \
            --with-threads \
            --with-libs="-lbz2 -lreadline -lncurses -lhistory -lsqlite3 -lssl" \
            --enable-shared \
            --with-system-expat \
            --with-system-ffi   \
            --with-ensurepip=yes \
            --enable-unicode=ucs4 \
            --disable-ipv6
RUN cd /opt/cpython && make -j16
RUN cd /opt/cpython && make install

Tensorflow构建命令:

代码语言:javascript
复制
bazel build   --copt=-O3  --copt=-mtune=skylake-avx512 --copt=-march=skylake-avx512        //tensorflow/tools/pip_package:build_pip_package
./bazel-bin/tensorflow/tools/pip_package/build_pip_package /mnt

只有选项集XLA,其他所有设置为“否”。我使用的tensorflow v1.12.0-devel的对接图像,我是复制标签v1.12.3。

为完整起见:

代码语言:javascript
复制
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.15.0 installed.
Please specify the location of python. [Default is /usr/local/bin/python]: 


Found possible Python library paths:
  /usr/local/lib/python2.7/site-packages
Please input the desired Python library path to use.  Default is [/usr/local/lib/python2.7/site-packages]

Do you wish to build TensorFlow with Apache Ignite support? [Y/n]: n
No Apache Ignite support will be enabled for TensorFlow.

Do you wish to build TensorFlow with XLA JIT support? [Y/n]: Y
XLA JIT support will be enabled for TensorFlow.

Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: n
No OpenCL SYCL support will be enabled for TensorFlow.

Do you wish to build TensorFlow with ROCm support? [y/N]: n
No ROCm support will be enabled for TensorFlow.

Do you wish to build TensorFlow with CUDA support? [y/N]: n
No CUDA support will be enabled for TensorFlow.

Do you wish to download a fresh release of clang? (Experimental) [y/N]: n
Clang will not be downloaded.

Do you wish to build TensorFlow with MPI support? [y/N]: n
No MPI support will be enabled for TensorFlow.

Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]: -O3 -mtune=skylake-avx512 -march=skylake-avx512


Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: n
Not configuring the WORKSPACE for Android builds.

Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See tools/bazel.rc for more details.
    --config=mkl            # Build with MKL support.
    --config=monolithic     # Config for mostly static monolithic build.
    --config=gdr            # Build with GDR support.
    --config=verbs          # Build with libverbs support.
    --config=ngraph         # Build with Intel nGraph support.
Configuration finished

我在对付gcc-9,g+-9,和ubuntu 16.04.在此之前,我已经修过几个羊肉,但我不知道我在这里错过了什么。有人能帮我解决这个丢失的符号吗?

代码语言:javascript
复制
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: /usr/local/lib/python2.7/site-packages/tensorflow/python/../libtensorflow_framework.so: undefined symbol: __cpu_model


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.```
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-08 19:55:58

我解决了问题。

之所以会发生这种情况,是因为我正在一个容器中构建tensorflow,获取车轮文件并在另一个容器中安装tensorflow。

除非tensorflow的所有相关库都以相同的方式构建,即包含正确的符号和符号/库的版本,否则在容器tensorflow中都会生成tensorflow,并且会出现类似这些问题的容器。我和其他图书馆一起在我的另一个容器里建造了蟒蛇、矮胖和熊猫。在我从源代码构建了这些库之后,当然是使用相同的标记版本,在系统上安装了相同的编译器标志和包之后,在tensorflow容器中,我的所有问题都消失了,tensorflow也能正常工作。

好奇的thing...tensorflow过去需要花费80+分钟来构建,在编译python和其他一些东西之后,现在大约需要35分钟才能构建。很贴心。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58244683

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档