在OS X 10.11.6上从源代码构建Tensorflow 13.1时出现问题

时间:2019-05-10 16:52:16

标签: tensorflow pip anaconda virtualenv bazel

我正在尝试从Mac上的源代码构建Tensorflow 13.1-OS X 10.11.6 我尝试使用bazel 0.21(macports),bazel 18.1和bazel 15.2。

bazel-0.18.1-installer-darwin-x86_64.sh
bazel-0.15.2-installer-darwin-x86_64.sh

成功从macports构建的带有bazel 0.21的Tensorflow 13.1的构建。 接下来,我构建一个.whl文件,并使用pip 19.1将其安装到我的Anaconda 3.6虚拟环境中。张量流的文件在: /用户/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages/tensorflow 缺失。只有包含文件。

当我尝试将tensorflow导入python 3.6 shell时,命令立即完成(不加载)。 显然,构建,安装或两者都有问题 AttributeError:模块“ tensorflow”没有属性“ 版本

$ port list bazel
bazel                          @0.21.0         devel/bazel

$ bazel version
WARNING: failed to raise resource limit 8 to 524288: Invalid argument
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 0fad439c-f23b-48e3-81e5-5e56b1e6cf24
Build label: 0.21.0- (@non-git)
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Feb 27 15:35:45 2019 (1551281745)
Build timestamp: 1551281745
Build timestamp as int: 1551281745

$ pip --version
pip 19.1.1 from /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages/pip (python 3.6)

$ bazel build //tensorflow/tools/pip_package:build_pip_package

$ ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

$sudo -H pip  install  /tmp/tensorflow_pkg/tensorflow-1.13.1-cp36-cp36m-macosx_10_7_x86_64.whl 

$ source activate ai
(ai) MacBook-Pro:~ davidlaxer$ python
Python 3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 14:01:38) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> print(tensorflow.__version__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute '__version__'
>>> quit()
(ai) MacBook-Pro:~ davidlaxer$ conda list tensorflow
# packages in environment at /Users/davidlaxer/anaconda/envs/ai:
#
# Name                    Version                   Build  Channel
tensorflow                1.13.1                    <pip>
tensorflow-estimator      1.13.0                    <pip>

(ai) MacBook-Pro:tensorflow davidlaxer$ which pip
/Users/davidlaxer/anaconda/envs/ai/bin/pip
(ai) MacBook-Pro:tensorflow davidlaxer$ sudo which pip
/Users/davidlaxer/anaconda/envs/ai/bin/pip
(ai) MacBook-Pro:tensorflow davidlaxer$  pip install /tmp/tensorflow_pkg/tensorflow-1.13.1-cp36-cp36m-macosx_10_7_x86_64.whl 
Requirement already satisfied: tensorflow==1.13.1 from file:///tmp/tensorflow_pkg/tensorflow-1.13.1-cp36-cp36m-macosx_10_7_x86_64.whl in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (1.13.1)
Requirement already satisfied: six>=1.10.0 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (1.12.0)
Requirement already satisfied: grpcio>=1.8.6 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (1.12.1)
Requirement already satisfied: wheel>=0.26 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (0.33.2)
Requirement already satisfied: absl-py>=0.1.6 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (0.2.2)
Requirement already satisfied: protobuf>=3.6.1 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (3.6.1)
Requirement already satisfied: keras-applications>=1.0.6 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (1.0.6)
Requirement already satisfied: termcolor>=1.1.0 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (1.1.0)
Requirement already satisfied: gast>=0.2.0 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (0.2.0)
Requirement already satisfied: numpy>=1.13.3 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (1.16.3)
Requirement already satisfied: keras-preprocessing>=1.0.5 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (1.0.9)
Requirement already satisfied: tensorboard<1.14.0,>=1.13.0 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (1.13.1)
Requirement already satisfied: tensorflow-estimator<1.14.0rc0,>=1.13.0 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (1.13.0)
Requirement already satisfied: astor>=0.6.0 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow==1.13.1) (0.6.2)
Requirement already satisfied: setuptools in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from protobuf>=3.6.1->tensorflow==1.13.1) (41.0.1)
Requirement already satisfied: h5py in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from keras-applications>=1.0.6->tensorflow==1.13.1) (2.8.0)
Requirement already satisfied: werkzeug>=0.11.15 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorboard<1.14.0,>=1.13.0->tensorflow==1.13.1) (0.14.1)
Requirement already satisfied: markdown>=2.6.8 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorboard<1.14.0,>=1.13.0->tensorflow==1.13.1) (2.6.11)
Requirement already satisfied: mock>=2.0.0 in /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages (from tensorflow-estimator<1.14.0rc0,>=1.13.0->tensorflow==1.13.1) (3.0.5)

我的张量文件应居住的虚拟环境目录只有一个include目录!


(ai) MacBook-Pro:tensorflow davidlaxer$ ls -l
total 0
drwxr-xr-x  8 root  staff  272 May 10 02:07 include

在Ubuntu上,所有文件都在那里!


ubuntu@ip-10-0-1-233:~/anaconda/envs/ai/lib/python3.6/site-packages/tensorflow$ ls -l
total 16976
drwxrwxr-x  4 ubuntu ubuntu     4096 Jan 15 16:37 _api
drwxrwxr-x  2 ubuntu ubuntu     4096 Jan 15 16:37 aux-bin
drwxrwxr-x  5 ubuntu ubuntu     4096 Jan 15 16:37 compiler
drwxrwxr-x 98 ubuntu ubuntu     4096 Jan 15 16:37 contrib
drwxrwxr-x 12 ubuntu ubuntu     4096 Jan 15 16:37 core
drwxrwxr-x  4 ubuntu ubuntu     4096 Jan 15 16:37 examples
drwxrwxr-x  9 ubuntu ubuntu     4096 Jan 15 16:37 include
-rw-rw-r--  2 ubuntu ubuntu    29128 Nov 13 22:59 __init__.py
-rwxrwxr-x  2 ubuntu ubuntu 17307888 Nov 13 23:01 libtensorflow_framework.so
drwxrwxr-x  2 ubuntu ubuntu     4096 Jan 15 16:37 __pycache__
drwxrwxr-x 26 ubuntu ubuntu     4096 Jan 15 16:37 python
drwxrwxr-x  7 ubuntu ubuntu     4096 Jan 15 16:37 tools

1 个答案:

答案 0 :(得分:0)

似乎Tensorflow 13.1现在需要macOS 10.12.6(Sierra)或更高版本(64 = bit)。 Tensorflow 12.0在OS X 10.11上仍然可以使用。

https://github.com/tensorflow/tensorflow/issues/28839

例如这是在更正Subgraph :: Indentity初始值设定项后在OS​​ X 10.11.6上构建Tensorflow 13.1的结果

ERROR: /Users/davidlaxer/tensorflow/tensorflow/contrib/ignite/BUILD:148:1: Executing genrule //tensorflow/contrib/ignite:gen_igfs_ops_pygenrule failed (Trace/breakpoint trap): bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped)
dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
  Referenced from: /private/var/tmp/_bazel_davidlaxer/f9fe21ec5c09226e5ca0dce9376abe82/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/contrib/ignite/../../../_solib_darwin_x86_64/_U_S_Stensorflow_Scontrib_Signite_Cgen_Ugen_Uigfs_Uops_Upy_Uwrappers_Ucc___Utensorflow/libtensorflow_framework.so (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _clock_gettime
  Referenced from: /private/var/tmp/_bazel_davidlaxer/f9fe21ec5c09226e5ca0dce9376abe82/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/contrib/ignite/../../../_solib_darwin_x86_64/_U_S_Stensorflow_Scontrib_Signite_Cgen_Ugen_Uigfs_Uops_Upy_Uwrappers_Ucc___Utensorflow/libtensorflow_framework.so (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib

/ bin / bash:第1行:53224跟踪/ BPT陷阱:5次攻击

https://github.com/tensorflow/tensorflow/issues/28839-out/host/bin/tensorflow/contrib/ignite/gen_gen_igfs_ops_py_wrappers_cc,''0 0> bazel-out / darwin-opt / genfiles / tensorflow / contrib / ignite / python / ops / gen_igfs_ops.py 目标// tensorflow / tools / pip_package:build_pip_package生成失败 使用--verbose_failures可以查看失败的构建步骤的命令行。 信息:经过时间:3007.455s,关键路径:200.07s INFO:2483进程:2483本地。 失败:构建未成功完成