在安装了cuda7.5和更新了cudnn版本之后,就可以进行TensorFlow的安装配置了,进入官方下载地址进行下载安装,tensorflow的github地址:https://github.com/tensorflow/tensorflow。
具体安装只需一条指令,
sudo pip install /home/lc/Downloads/tensorflow_gpu-rc0-cp27-none-linux_x86_64.whl
更换你自己的路径与文件名
此时安装路径为
/usr/local/lib/python2.7/dist-packages/
这不是本文要介绍的重点,依然要针对我安装过程时出现的问题,进行相关的展开。
Traceback (most recent call last):
File "<stdin>", line , in <module>
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py", line , in <module>
from tensorflow.python import *
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line , in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line , in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line , in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line , in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line , in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcusolver.so: cannot open shared object file: No such file or directory
当我Python命令行中输入语句
出现以上错误,查了很多别人的疑问解答,都是以改变环境变量为主,
sudo vim ~/.bashrc
export LD_LIBRARY_PATH=”$LD_LIBRARY_PATH:/usr/local/cuda/lib64”
export CUDA_HOME=/usr/local/cuda
source ~/.bashrc
但我这么做以后依然没有解决,
仔细分析,其实不光是环境变量路径的问题,TensorFlow现在的安装版本适配的应该是cuda8.0的,而我安装的是cuda7.5版本,所以需要降级版本安装,
可能有些人的电脑pip安装还会出现一些问题,在安装之前最好执行以下语句,
这一条是针对的Python2版本,如果你是Python3(sudo apt-get install python3-pip )
安装之后,运行TensorFlow的运行检测,如果正常就说明万事大吉了。
我的是还遇到了下面的问题,
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line , in <module>
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/__init__.py", line , in <module>
from tensorflow.python import *
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/__init__.py", line , in <module>
from tensorflow.python.platform import test
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/platform/test.py", line , in <module>
import mock # pylint: disable=g-import-not-at-top,unused-import
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mock/__init__.py", line , in <module>
import mock.mock as _mock
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mock/mock.py", line , in <module>
from pbr.version import VersionInfo
ImportError: No module named pbr.version
针对这个问题,你只需要
sudo pip install pbr funcsigs
即可修复。
以上皆是我在安装时遇到的各种问题,通过搜索相关资料,最后都进行了有效的解决,希望能给你有用的参考。