LINUX下安装tensorflow

2018-12-19

linux(centos)下进行tensorflow的CPU版本安装,python版本是3.6,使用的方法是pip

1.安装python

  到目前为止,TensorFlow暂时只支持python3.4,3.5和3.6的,还支持python2.x。官网见这里。

  如果安装了python3.7的话,可以直接安装python3.6,不需要对3.7做处理,安装方法见之前的博客

2.安装pip

  一般情况下,安装完Python3.6后,会成功安装上pip,可以通过下面的代码来检查是否安装成功

[root@localhost ~]# pip --version
pip 18.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

  可能pip不是最新版,此时需要更新一下,免得后面使用pip来安装TensorFlow时出错。但更新的时候会报错,说不支持SSL,所以这要如下操作下

[root@localhost Python-3.6.7]# yum install openssl-devel -y   
[root@localhost Python-3.6.7]# cd /server/tools/Python-3.6.7/ # 进入到python的安装目录处,每个人的安装目录都不一样
[root@localhost Python-3.6.7]# make clean
[root@localhost Python-3.6.7]# ./configure [root@localhost Python-3.6.7]# make && make install [root@localhost Python-3.6.7]# python -m pip install --upgrade pip

3.安装TensorFlow

  接下来使用pip命令来安装TensorFlow即可,此版本是CPU版本,下载时间会有点久。

扫描二维码关注公众号,回复: 4566782 查看本文章
[root@localhost Python-3.6.7]# pip3 install --upgrade tensorflow #CPU版本
[root@localhost Python-3.6.7]# pip3 install --upgrade tensorflow #GPU版本,选择一个即可

  安装完后,进入Python编程,检测是否成功

Python 3.6.7 (default, Dec 19 2018, 12:25:37) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>

  若没有错误消息,则说明安装成功

猜你喜欢

转载自www.cnblogs.com/dengshunge/p/10143341.html