我对tensorflow安装感到头疼......
我有CUDA 8,CUdnn 6和UBUNTU 16.04,python 2.7
我现在要安装yensorflow。我已经按照他们在网站上安装的说明进行了安装,但我有版本匹配的库。 当我使用caffe时,我不想改变那些版本。所以我不得不寻找旧版本的tensorflow。
但我找不到安装它的好方法。每次只是故障。我现在很累。
我是这样的: 1-从这里下载tensorflow r1.4: https://github.com/tensorflow/tensorflow/tree/r1.4
2-我的'LD_LIBRARY_PATH'是:
:/usr/local/cuda-8.0/lib64/:/usr/local/cuda/lib64:/home/aa/torch/install/lib:/usr/lib/
3-我成功地运行了这个:
$ sudo apt-get install python-pip python-dev python-virtualenv # for Python 2.7
4-和这个:
$ virtualenv --system-site-packages targetDirectory # for Python 2.7
5-我激活环境
$ source ~/tensorflow/bin/activate
6-和
(tensorflow)$ easy_install -U pip
直到这里,一切都很好。
7-当我运行此行时
pip install --upgrade tensorflow-gpu
使用此消息成功完成:
Successfully installed absl-py-0.1.10 numpy-1.14.1 protobuf-3.5.1 setuptools-38.5.1 six-1.11.0 tensorflow-gpu-1.5.0 tensorflow-tensorboard-1.5.1 werkzeug-0.14.1 wheel-0.30.0
但是我无法在python中导入它并且给出了这条消息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
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.
我想我应该选择旧版本。
我确实安装了旧版本 但是当我在python中测试安装时,我看到了这样的消息:
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/node_def_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/resource_handle_pb2.py", line 22, in <module>
serialized_pb=_b('\n/tensorflow/core/framework/resource_handle.proto\x12\ntensorflow\"r\n\x13ResourceHandleProto\x12\x0e\n\x06\x64\x65vice\x18\x01 \x01(\t\x12\x11\n\tcontainer\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x11\n\thash_code\x18\x04 \x01(\x04\x12\x17\n\x0fmaybe_type_name\x18\x05 \x01(\tB/\n\x18org.tensorflow.frameworkB\x0eResourceHandleP\x01\xf8\x01\x01\x62\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
答案 0 :(得分:4)
您应该可以使用
安装早期版本的tensorflowpip install tensorflow == 1.3其中1.3是版本号。您可以选择您选择的版本。
答案 1 :(得分:3)
你可以在这里https://pypi.python.org/pypi/tensorflow/1.4.0找到tensorflow的.whl文件并使用pip安装它。
如果你想要旧版本更改网址https://pypi.python.org/pypi/tensorflow/1.x.0(x= version you want)
答案 2 :(得分:0)
&#39;问题解决了。 我有&#34; /usr/lib/python2.7/dist-packages"在我的PYTHONPATH。 因此,protobufs之间存在版本不匹配,并且通过键入&#39; unset PYTHONPATH&#39;来解决它。在开始导入tensorflow之前。