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 ~]$
成功