无法使用tensorflow
问题描述:
我通过pip在我的mac上安装了tensorflow,我使用的是anaconda作为我的IDE。 当我运行无法使用tensorflow
import tensoflow
我得到以下错误的命令:
Traceback (most recent call last):
File "<ipython-input-3-a649b509054f>", line 1, in <module>
import tensorflow
File "/Applications/anaconda3/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Applications/anaconda3/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Applications/anaconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Applications/anaconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Applications/anaconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Applications/anaconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/Applications/anaconda3/lib/python3.5/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/Applications/anaconda3/lib/python3.5/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: dlopen(/Applications/anaconda3/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: @rpath/libcublas.8.0.dylib
Referenced from: /Applications/anaconda3/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
Reason: image not found
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
我也在我的终端跑到pip list
检查它是否被正确安装。它列出了我已经安装的所有tensorflow库。
我使用蟒蛇v1.6.8和Spyder的V3.2.3
答
我可以看到你有2个版本tensorflow的。 (1.1.0)和无(1.3.0)gpu支持。但是你得到的错误是因为gpu库没有正确安装。
对于tensorflow-gpu==1.1.0
关注these instructions。
不幸的是tensorflow dropped support for gpu on Mac since v1.2,但这answer可能会帮助您设置更高版本。
你的Mac有NVIDIA GPU吗? – mrry
Macs没有Nvidia GPU,所以我不认为使用GPU版本会对我有好处。所以我应该卸载tensorflow-gpu吗? – Rasik
是的,卸载'tensorflow-gpu'应该可以解决这个问题。 – mrry