0
votes

I am trying to build tensorflow 13.1 from source on my Mac - OS X 10.11.6 I have tried with bazel 0.21 (macports), bazel 18.1 and bazel 15.2.

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

The build of Tensorflow 13.1 with bazel 0.21 from macports built successfully. Next I build a .whl file and installed it with pip 19.1 into my Anaconda 3.6 virtual environment. The files for tensorflow in: /Users/davidlaxer/anaconda/envs/ai/lib/python3.6/site-packages/tensorflow are missing. There are only include files.

When I try to import tensorflow into a python 3.6 shell, the command finishes instantly (without loading). Clearly, something is wrong with the build, the installation or both AttributeError: module 'tensorflow' has no attribute 'version'

$ 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)

The directory for my virtual environment where my tensorfiles should live only has an include directory!


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

On Ubuntu, all the files are there!


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
Run unzip -l tensorflow-1.13.1-cp36-cp36m-macosx_10_7_x86_64.whl; if the files are not in the wheel, it wasn't built correctly; check out the build output for possible errors. - hoefling
The .whl only has the include files. - dbl001

1 Answers

0
votes

It seems that Tensorflow 13.1 now requires macOS 10.12.6 (Sierra) or later (64=bit). Tensorflow 12.0 does still work on OS X 10.11.

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

E.g. Here's what happens building tensorflow 13.1 on OS X 10.11.6 after correcting the Subgraph::Indentity initializer

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: line 1: 53224 Trace/BPT trap: 5 baze

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 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: 3007.455s, Critical Path: 200.07s INFO: 2483 processes: 2483 local. FAILED: Build did NOT complete successfully