CentOS7利用pip快速安装TensorFlow
来自CloudWiki
参考文档:https://blog.csdn.net/ai_bigdata_wh/article/details/77865616
pip安装
首先检查CentOS有没有安装python-pip包,直接执行:yum install python-pip
如果提示:
Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: mirrors.neusoft.edu.cn * updates: mirrors.neusoft.edu.cn No package python-pip available.
如提示没有python-pip包,可对yum的软件仓库提供额外的软件包,执行命令: yum -y install epel-release。
Downloading packages: epel-release-7-11.noarch.rpm | 15 kB 00:21 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : epel-release-7-11.noarch 1/1 Verifying : epel-release-7-11.noarch 1/1 Installed: epel-release.noarch 0:7-11 Complete!
执行成功之后,再次执行:yum install python-pip
Installed: python2-pip.noarch 0:8.1.2-6.el7 Dependency Installed: python-backports.x86_64 0:1.0-8.el7 python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 python-ipaddress.noarch 0:1.0.16-2.el7 python-setuptools.noarch 0:0.9.8-7.el7 Complete!
pip升级
此时安装好的pip版本为0.8,非最新版本,可对其进行升级
[root@tensorflow ~]# pip install --upgrade pip
Installing collected packages: pip Found existing installation: pip 8.1.2 Uninstalling pip-8.1.2: Successfully uninstalled pip-8.1.2 Successfully installed pip-18.0
TensorFlow安装
升级成功之后,便可以通过pip快速地安装TensorFlow:
pip install tensorflow
TensorFlow版本查看
执行以下代码对TF的版本进行查看:
[root@tensorflow ~]# python Python 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> tf.__version__ '1.9.0'
TensorFlow验证
执行一下代码对TensorFlow是否成功安装进行验证 [root@tensorflow ~]# python
Python 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> hello = tf.constant('Hello,World') >>> sess = tf.Session() 2018-08-08 14:17:32.742209: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA >>> print sess.run(hello) Hello,World