在 Intel Atom 上构建 Tensorflow 的错误
Errors on building Tensorflow on Intel Atom
我在 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
安装说明:
- 确保 numpy, keras-applications, keras-preprocessing, pip, six,
wheel, mock 包安装在 Python 环境中
正在构建和安装 TensorFlow。
克隆 TensorFlow 源代码并签出 1.12 分支
git clone https://github.com/tensorflow/tensorflow
git checkout r1.12
运行 来自 TensorFlow 源目录的“./configure”
执行以下命令创建可用于安装优化的 TensorFlow 构建的 pip 包。
PATH 可以更改为指向特定版本的 GCC 编译器:
export PATH=/PATH//bin:$PATH
LD_LIBRARY_PATH也可以是新的:
export LD_LIBRARY_PATH=/PATH//lib64:$LD_LIBRARY_PATH
在您的机器上设置 GCC 支持的编译器标志,以使用英特尔® 数学核心函数库(英特尔® 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
(或)
或者,设置适当的 "Instruction sets" 标志来编译库:
Flags set in the command below will add AVX, AVX2 and AVX512 instructions which will result in "illegal instruction" errors when you use older CPUs. If you want to build on older CPUs, set the instruction flags accordingly
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 wheel
bazel-bin/tensorflow/tools/pip_package/build_pip_package ~/path_to_save_wheel
pip install --upgrade --user ~/path_to_save_wheel/<wheel_name.whl>
作为参考,请阅读此link:https://software.intel.com/en-us/articles/intel-optimization-for-tensorflow-installation-guide
我在 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
安装说明:
- 确保 numpy, keras-applications, keras-preprocessing, pip, six, wheel, mock 包安装在 Python 环境中 正在构建和安装 TensorFlow。
克隆 TensorFlow 源代码并签出 1.12 分支
git clone https://github.com/tensorflow/tensorflow git checkout r1.12
运行 来自 TensorFlow 源目录的“./configure”
执行以下命令创建可用于安装优化的 TensorFlow 构建的 pip 包。
PATH 可以更改为指向特定版本的 GCC 编译器:
export PATH=/PATH//bin:$PATH
LD_LIBRARY_PATH也可以是新的:
export LD_LIBRARY_PATH=/PATH//lib64:$LD_LIBRARY_PATH
在您的机器上设置 GCC 支持的编译器标志,以使用英特尔® 数学核心函数库(英特尔® 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
(或)
或者,设置适当的 "Instruction sets" 标志来编译库:
Flags set in the command below will add AVX, AVX2 and AVX512 instructions which will result in "illegal instruction" errors when you use older CPUs. If you want to build on older CPUs, set the instruction flags accordingly
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 wheel
bazel-bin/tensorflow/tools/pip_package/build_pip_package ~/path_to_save_wheel pip install --upgrade --user ~/path_to_save_wheel/<wheel_name.whl>
作为参考,请阅读此link:https://software.intel.com/en-us/articles/intel-optimization-for-tensorflow-installation-guide