在Mac OS上安装TensorFlow的问题(10.12.1)

时间:2016-12-04 18:12:48

标签: python macos python-2.7 tensorflow

我已经花了3个多小时安装了支持GPU的TensorFlow,但它仍然没有用。

我选择了“pip”安装指南。

以下是我按顺序完成的任务:

1.1下载并安装CUDA工具包(.dmg v8.0)

1.2下载并解压缩CUDA深度神经网络(cuDNN v5)

1.3复制文件

cd ~/Downloads/cuda
sudo mv include/cudnn.h /Developer/NVIDIA/CUDA-8.0/include/
sudo mv lib/libcudnn* /Developer/NVIDIA/CUDA-8.0/lib
sudo ln -s /Developer/NVIDIA/CUDA-8.0/lib/libcudnn* /usr/local/cuda/lib/

2.1设置变量

export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64"
export DYLD_LIBRARY_PATH="$CUDA_HOME/lib"
export PATH="$CUDA_HOME/bin:$PATH"

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.0rc0-py2-none-any.whl

3.1安装点

sudo easy_install pip

3.2安装tensorflow

sudo pip install tensorflow --ignore-installed numpy

3.3安装二进制文件

sudo pip install --upgrade $TF_BINARY_URL

最后,当我想检查TensorFlow是否正常工作时,我输入Python并简单地导入它:

>>> import tensorflow as tf

以下是我收到的完整错误消息:

dyld: warning, LC_RPATH $ORIGIN/../../_solib_darwin/_U@local_Uconfig_Ucuda_S_Scuda_Ccudart___Uexternal_Slocal_Uconfig_Ucuda_Scuda_Slib in /Library/Python/2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so being ignored in restricted program because it is a relative path
dyld: warning, LC_RPATH ../local_config_cuda/cuda/lib in /Library/Python/2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so being ignored in restricted program because it is a relative path
dyld: warning, LC_RPATH ../local_config_cuda/cuda/extras/CUPTI/lib in /Library/Python/2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so being ignored in restricted program because it is a relative path
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py", line 60, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: dlopen(/Library/Python/2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Library not loaded: @rpath/libcudart.8.0.dylib
  Referenced from: /Library/Python/2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so
  Reason: image not found

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

好像很简单


const NavContainer = ReactRedux.connect(
    MapStateToProps,
    MapDispatchToProps,
    null,
    {pure: false}
)(Nav)

做了诀窍......