为什么不能使用python 3使用新安装的TensorFlow库?

时间:2016-08-28 23:57:26

标签: python tensorflow

我最近升级到python 3.5,并尝试使用TensorFlow。我按照说明https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html安装了启用GPU的tensorflow:

# Mac OS X, GPU enabled, Python 3.4 or 3.5:
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow-0.10.0rc0-py3-none-any.whl

然而,当我尝试使用tensorflow时,它引发了一个非常奇怪的错误:

>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/user/path/venv2/lib/python3.5/site-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/Users/user/path/venv/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 48, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Users/user/path/venv/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/Users/user/path/venv/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
  File "/Users/user/path/venv/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/Users/user/path/venv/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: dlopen(/Users/user/path/venv/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Library not loaded: @rpath/libcudart.7.5.dylib
  Referenced from: /Users/user/path/venv/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so
  Reason: image not found

为什么会抛出这个错误?我知道我没有GPU,但我在TensorFlow页面上的其他对话的印象中,我不需要使用可能使用GPU的版本。

1 个答案:

答案 0 :(得分:0)

您需要在export DYLD_LIBRARY_PATH

中使用~/.bash_profile将路径导出到cuda dylibs的文件夹(例如libcudart)