我在Intel Atom上构建Tensorflow。淡褐色为0.15。要构建的控制台命令是
bazel build --config=mkl --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0 --copt=-march=atom --copt=-mtune=atom //tensorflow/tools/pip_package:build_pip_package
我有
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
两个错误是
ERROR: /home/upsquared/tensorflow/tensorflow/BUILD:533:1: Executing genrule //tensorflow:tf_python_api_gen_v1 failed (Exit 1)
Traceback (most recent call last):
ImportError: /home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyClass_Type
整个错误消息为
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-self-assign'
ERROR: /home/upsquared/tensorflow/tensorflow/BUILD:533:1: Executing genrule //tensorflow:tf_python_api_gen_v1 failed (Exit 1)
Traceback (most recent call last):
File "/home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/upsquared/venv/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/upsquared/venv/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyClass_Type
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/tools/api/generator/create_python_api.py", line 27, in <module>
from tensorflow.python.tools.api.generator import doc_srcs
File "/home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/upsquared/venv/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/upsquared/venv/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/upsquared/.cache/bazel/_bazel_upsquared/64ad7d1d27724ec626c14ec5fee17883/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyClass_Type
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.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 7602.740s, Critical Path: 240.17s
INFO: 5845 processes: 5845 local.
FAILED: Build did NOT complete successfully
答案 0 :(得分:0)
安装说明:
克隆TensorFlow源代码并检出1.12分支
git clone https://github.com/tensorflow/tensorflow
git checkout r1.12
在TensorFlow源目录中运行“ ./configure”
执行以下命令来创建一个pip软件包,该软件包可用于安装优化的TensorFlow构建。
可以将PATH更改为指向特定版本的GCC编译器:
export PATH=/PATH//bin:$PATH
LD_LIBRARY_PATH也可以是新的:
export LD_LIBRARY_PATH=/PATH//lib64:$LD_LIBRARY_PATH
设置计算机上GCC支持的编译器标志,以使用Intel®Math Kernel Library(Intel®MKL)构建TensorFlow。确保设置了适当的“ march”和“ mtune”标志。
bazel build --config=mkl --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0 --copt=-march=sandybridge --copt=-mtune=ivybridge --copt=-O3 //tensorflow/tools/pip_package:build_pip_package
(或)
或者,使用以下方法设置要编译库的适当“指令集”标志:
在以下命令中设置的标记将添加AVX,AVX2和AVX512指令,当您使用旧版CPU时,这将导致“非法指令”错误。如果要在较旧的CPU上构建,请相应地设置指令标志
bazel build --config=mkl -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mavx512f --copt=-mavx512pf --copt=-mavx512cd --copt=-mavx512er //tensorflow/tools/pip_package:build_pip_package
安装优化的TensorFlow滚轮
bazel-bin/tensorflow/tools/pip_package/build_pip_package ~/path_to_save_wheel
pip install --upgrade --user ~/path_to_save_wheel/<wheel_name.whl>
作为参考,请通过以下链接:https://software.intel.com/en-us/articles/intel-optimization-for-tensorflow-installation-guide