Tensor flow安装OSX

时间:2015-11-16 02:40:31

标签: tensorflow

我试图在El 10.11.1上安装TensorFlow,而且我在创建和安装我根本不了解的pip包时遇到了问题。

我成功安装了Bazel,SWIG和NumPy per instructions(至少他们现在似乎都工作了。)

创建pip包/ install运行命令时出现以下错误:

bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
  

/ Users / christophermichael / tensorflow / tensorflow / tensorflow / python / BUILD:730:1:C ++编译规则' // tensorflow / python:_pywrap_tensorflow.so'失败:osx_gcc_wrapper.sh失败:执行命令错误

使用--verbose_failures运行,我得到:

/Users/christophermichael/tensorflow/tensorflow/tensorflow/python/BUILD:730:1: C++ compilation of rule '//tensorflow/python:_pywrap_tensorflow.so' failed: osx_gcc_wrapper.sh failed: error executing command 
(cd /private/var/tmp/_bazel_christophermichael/b14fc0915a4b8dd526e88d50650b0640/tensorflow && \
  exec env - \
    INTERCEPT_LOCALLY_EXECUTABLE=1 \
    PATH=/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/christophermichael/bin \
    TMPDIR=/var/folders/tv/rgqv4fp54mn952pn_v0tjwt80000gn/T/ \
  tools/cpp/osx_gcc_wrapper.sh '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -iquote . -iquote bazel-out/local_darwin-opt/genfiles -isystem google/protobuf/src -isystem bazel-out/local_darwin-opt/genfiles/google/protobuf/src -isystem tools/cpp/gcc3 -isystem external/jpeg_archive/jpeg-9a -isystem bazel-out/local_darwin-opt/genfiles/external/jpeg_archive/jpeg-9a -isystem external/png_archive/libpng-1.2.53 -isystem bazel-out/local_darwin-opt/genfiles/external/png_archive/libpng-1.2.53 -isystem external/re2 -isystem bazel-out/local_darwin-opt/genfiles/external/re2 -isystem third_party/gpus/cuda -isystem bazel-out/local_darwin-opt/genfiles/third_party/gpus/cuda -isystem third_party/gpus/cuda/include -isystem bazel-out/local_darwin-opt/genfiles/third_party/gpus/cuda/include -isystem third_party/eigen3 -isystem bazel-out/local_darwin-opt/genfiles/third_party/eigen3 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -Wno-self-assign -Wno-write-strings -I/usr/include/python2.7 -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' '-frandom-seed=bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/_pywrap_tensorflow.so/tensorflow/python/pywrap_tensorflow.pic.o' -MD -MF bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/_pywrap_tensorflow.so/tensorflow/python/pywrap_tensorflow.pic.d -fPIC -c bazel-out/local_darwin-opt/bin/tensorflow/python/pywrap_tensorflow.cc -o bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/_pywrap_tensorflow.so/tensorflow/python/pywrap_tensorflow.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1: osx_gcc_wrapper.sh failed: error executing command 
  (cd /private/var/tmp/_bazel_christophermichael/b14fc0915a4b8dd526e88d50650b0640/tensorflow && \
  exec env - \
    INTERCEPT_LOCALLY_EXECUTABLE=1 \
    PATH=/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/christophermichael/bin \
    TMPDIR=/var/folders/tv/rgqv4fp54mn952pn_v0tjwt80000gn/T/ \
  tools/cpp/osx_gcc_wrapper.sh '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -iquote . -iquote bazel-out/local_darwin-opt/genfiles -isystem google/protobuf/src -isystem bazel-out/local_darwin-opt/genfiles/google/protobuf/src -isystem tools/cpp/gcc3 -isystem external/jpeg_archive/jpeg-9a -isystem bazel-out/local_darwin-opt/genfiles/external/jpeg_archive/jpeg-9a -isystem external/png_archive/libpng-1.2.53 -isystem bazel-out/local_darwin-opt/genfiles/external/png_archive/libpng-1.2.53 -isystem external/re2 -isystem bazel-out/local_darwin-opt/genfiles/external/re2 -isystem third_party/gpus/cuda -isystem bazel-out/local_darwin-opt/genfiles/third_party/gpus/cuda -isystem third_party/gpus/cuda/include -isystem bazel-out/local_darwin-opt/genfiles/third_party/gpus/cuda/include -isystem third_party/eigen3 -isystem bazel-out/local_darwin-opt/genfiles/third_party/eigen3 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -Wno-self-assign -Wno-write-strings -I/usr/include/python2.7 -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' '-frandom-seed=bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/_pywrap_tensorflow.so/tensorflow/python/pywrap_tensorflow.pic.o' -MD -MF bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/_pywrap_tensorflow.so/tensorflow/python/pywrap_tensorflow.pic.d -fPIC -c bazel-out/local_darwin-opt/bin/tensorflow/python/pywrap_tensorflow.cc -o bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/_pywrap_tensorflow.so/tensorflow/python/pywrap_tensorflow.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 4.940s, Critical Path: 3.69s

3 个答案:

答案 0 :(得分:4)

是的,正如Hamed上面所说,最好直接安装二进制文件。

但是,如果您确实需要从源代码构建,那么这些步骤应该有效:

  • brew install python
  • virtualenv ~/tf
  • source ~/tf/bin/activate
  • 安装bazel for Mac
  • 为Mac安装PCRE(不是PCRE2)
  • 安装SWIG for Mac
  • git clone --recurse-submodules https://github.com/tensorflow/tensorflow
  • cd tensorflow
  • ./configure
  • bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
  • bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
  • pip install /tmp/tensorflow_pkg/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
  • bazel build -c opt //tensorflow/cc:tutorials_example_trainer

答案 1 :(得分:3)

另一个选择是安装anaconda并使用其环境管理。使用anaconda或virtualenv的环境的优点是您可以为不同的用例分离源和依赖项。这意味着,如果您需要对python库进行其他更改,则不会影响您的tensorflow环境。

以下是如何使用anaconda安装tensorflow。

  1. 安装anaconda http://docs.continuum.io/anaconda/install
  2. 创建新的conda工作区
  3. 下载tensorflow需要的特定protobuf版本:https://pypi.python.org/pypi/protobuf/3.0.0a3
  4. 通过sudo easy_install ~/Downloads/protobuf-3.0.0a3-py2.7.egg
  5. 安装
  6. 通过conda install numpy
  7. 安装大于1.08.x的numpy版本
  8. 下载tensorflow的0.6.0版本: https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py2-none-any.whl

  9. 通过pip install ~/Downloads/tensorflow-0.6.0-py2-none-any.whl

  10. 安装

    安装时     从whl文件直接的tensorflow,它应该告诉你什么时候     依赖不存在。似乎无法解决这些问题     独立冲突。我的设置与protobuf和     numpy的。手动安装后,一切正常。

    我希望这有帮助!

答案 2 :(得分:1)

为什么要从源代码安装?

创建一个virtualenv并在那里安装它,我有相同的操作系统版本,它可以通过这种方法工作得非常好:

https://stackoverflow.com/a/33691154/1973820

相关问题