2015-11-16 92 views
6

我想在El 10.11.1上安裝TensorFlow,而且我在創建和安裝我根本不瞭解的pip軟件包時遇到了問題。張量流安裝OSX

我成功安裝了Bazel,SWIG和NumPy per instructions(至少它們現在似乎都在工作)。

創建PIP包/安裝我得到以下錯誤,當我運行命令:

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

/用戶/ christophermichael/tensorflow/tensorflow/tensorflow /蟒/ 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 
+1

哎喲我的眼裏,*牆代碼... * – Coffee

+0

你能縮小誤差降低到什麼有關? – Coffee

+1

我認爲gcc出了問題?我敢遠遠超過我這裏頭要安裝這樣的:/用戶/ christophermichael/tensorflow/tensorflow/tensorflow /蟒蛇/ BUILD:730:1: '//tensorflow/python:_pywrap_tensorflow.so' 失敗規則的C++編譯: osx_gcc_wrapper.sh失敗 – user5565899

回答

1

爲什麼要從源代碼安裝?

創建的virtualenv並安裝它,我有相同的操作系統版本,它的工作原理超細從此方法:

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

+0

謝謝,我會盡力的。我從來沒有使用過virtualenv,並認爲從源代碼安裝可能更容易。 – user5565899

+1

感謝它的工作! – user5565899

4

呀,因爲哈米德上面說的,最好直接安裝二進制文件。

但是,如果你確實需要從源頭上構建,那麼這些步驟應該工作:

  • brew install python
  • virtualenv ~/tf
  • source ~/tf/bin/activate
  • 爲Mac安裝巴澤勒
  • 安裝PCRE(而不是PCRE2)for Mac
  • 安裝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
+0

在我的情況下,我添加更改'pip install ...'在'pip install /tmp/tensorflow_pkg/tensorflow-0.8.0-py2-none-any.whl' – loretoparisi

3

另一種選擇是安裝蟒蛇,並使用其環境法力gement。與anaconda或virtualenv一起使用環境的優點是,可以爲不同的用例分隔源和依賴關係。這意味着,如果您需要對其他庫中的python庫進行更改,它不會影響您的tensorflow環境。

以下是如何安裝anaconda的tensorflow。

  1. 安裝蟒蛇http://docs.continuum.io/anaconda/install
  2. 創建一個新的工作區康達
  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. 安裝它安裝numpy的版本通過除1.08.x更大conda install numpy
  6. 下載0.6.0版本tensorflow的: https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py2-none-any.whl

  7. 通過pip install ~/Downloads/tensorflow-0.6.0-py2-none-any.whl

安裝當您從WHL文件直接安裝 tensorflow,它應該告訴你什麼時候 依賴關係不存在。它似乎不能獨立解決這些衝突。我的設置與protobuf和 numpy有問題。手動安裝它們後,一切正常。

我希望這有助於!