Tensorflow安装OS X

2024-01-16

我正在尝试在 El 10.11.1 上安装 TensorFlow,但在创建和安装 pip 包时遇到问题,我根本不理解。

我成功安装了 Bazel、SWIG 和 NumPy按照说明 http://tensorflow.org/get_started/os_setup.md(至少此时它们似乎都起作用)。

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

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

/Users/christophermichael/tensorflow/tensorflow/tensorflow/python/BUILD:730:1:规则“//tensorflow/python:_pywrap_tensorflow.so”的 C++ 编译失败:osx_gcc_wrapper.sh 失败:执行命令时出错

跑步与--verbose_failures, I get:

/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

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

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

  • brew install python
  • virtualenv ~/tf
  • source ~/tf/bin/activate
  • 安装 Mac 版 bazel
  • 为 Mac 安装 PCRE(不是 PCRE2)
  • 安装 Mac 版 SWIG
  • 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Tensorflow安装OS X 的相关文章

随机推荐