CentOS7+ anaconda3 + Python-3.6 + tensorflow-cpu-1.5安装和配置

CentOS7+ anaconda3 + Python-3.6 + tensorflow-cpu-1.5安装和配置
=============================================================================
本博客,博文:CentOS7服务器上部署深度/机器学习环境推荐首选anaconda3 链接https://www.cnblogs.com/jeshy/p/10522379.html
可能会出错:
>>> import tensorflow as tf
Illegal instruction
本文主要解决此问题(降低版本)
=============================================================================
(base) [jiangshan@localhost ~]$ conda info -e
# conda environments:
#
base * /home/jiangshan/anaconda3
tensorflow /home/jiangshan/anaconda3/envs/tensorflow

==========先卸载和删除掉先前创建 的tensorflow虚拟环境=======================

(base) [jiangshan@localhost ~]$ conda remove --name tensorflow --all

==========先卸载和删除掉先前创建 的tensorflow虚拟环境=======================

(base) [jiangshan@localhost ~]$ conda info -e
# conda environments:
#
base * /home/jiangshan/anaconda3

(base) [jiangshan@localhost ~]$ conda create --name tensorflow python=3.6
(base) [jiangshan@localhost ~]$ conda activate tensorflow

添加设置镜像
# 添加tensorflow的Linux/cpu清华镜像
(tensorflow) [jiangshan@localhost ~]$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/
# 设置搜索时显示通道地址
(tensorflow) [jiangshan@localhost ~]$ conda config --set show_channel_urls yes
**************************************************************************
安装 tensorflow1.8.0
(tensorflow) [jiangshan@localhost ~]$ conda install tensorflow==1.8
以上会出错,改为以下用pip从源码安装
(tensorflow) [jiangshan@localhost ~]$ pip install tensorflow==1.8
测试==报错==
Python 3.6.7 | packaged by conda-forge | (default, Feb 28 2019, 09:07:38)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Illegal instruction
补救 卸载 tensorflow1.8 改安装较低版本的tensorflow(我来来回回降到了1.5版)
(tensorflow) [jiangshan@localhost ~]$ pip uninstall tensorflow
**************************************************************************
安装 tensorflow1.5
(tensorflow) [jiangshan@localhost ~]$ pip install tensorflow==1.5
测试
(tensorflow) [jiangshan@localhost ~]$ python
Python 3.6.7 | packaged by conda-forge | (default, Feb 28 2019, 09:07:38)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('你好!姜山~')
>>> sess = tf.Session()
2019-03-13 03:39:49.959697: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2
>>> print (sess.run(hello))
b'\xe4\xbd\xa0\xe5\xa5\xbd\xef\xbc\x81\xe5\xa7\x9c\xe5\xb1\xb1~'【我靠 不识别中文?????,赶紧换英文试试】

>>> hello = tf.constant('hhhh')
>>> sess = tf.Session()
>>> print (sess.run(hello))
b'hhhh'

>>> quit()
(tensorflow) [jiangshan@localhost ~]$ conda deactivate
(base) [jiangshan@localhost ~]$

成功

 

posted @ 2019-03-13 15:48  土博姜山山  阅读(2124)  评论(0编辑  收藏  举报