pip安装trensorflow,以及遇到的坑

在服务器上安装tensorflow,期间遇到各种坑,千辛万苦终于安装成功
前提是提前装好CUDA等各种包

我是采用pip安装的方式,安装GPU版本
首先pip安装版本tensorflow1.3.0
出现错误not a supported wheel on this platform,网上搜索了一些方法没解决,从而转至TensorFlow1.2试试,pip安装,版本位于:https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=gpu-linux/ ,最终使用该网页的tensorflow_gpu-1.2.1-cp27-none-linux_x86_64.whl版本安装成功

我是先下载该版本到本地再pip安装,命令行在线下载可能会很慢,命令如下:
sudo pip install –upgrade 加上 下载的包路径拖到此处
这里写图片描述
即可进行安装

测试时,运行python,测试import tensorflow,出现RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9错误,网上搜到是安装tensorflow numpy版本的问题
解决方案:先卸载tensorflow,命令:sudo pip uninstall tensorflow-gpu,再卸载numpy, 命令:sudo apt-get remove numpy,然后按照上面命令重新安装tensorflow

安装后测试import tensorflow,又出现 ImportError: cannot import name pywrap_tensorflow错误
错误解释: The real fix for me was to updated setuptools to the latest and it allowed me to upgrade mock and six to the latest. I was on setuptools 3.3. In my case I also had to remove said modules by hand because they were owned by OS in ‘/usr/local/lib/python2.7/dist-packages/’
check versions of everything
解决方式如下命令:
pip freeze | grep -e six -e mock
easy_install --version
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
pip install mock --upgrade
pip install six --upgrade

重新测试,Python 下import tensorflow,测试成功

你可能感兴趣的:(tensorflow,深度学习)