• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

麦子9

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

CentOS7.4安装TensorFlow步骤

CentOS7.4安装TensorFlow步骤:

1.使用pip工具安装tensorflow,要先安装pip。

# easy_install pip

2.使用pip安装tensorflow

# pip install tensorflow

PS:安装时遇到 :Found existing installation: numpy 1.7.1

Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.无法安装升级numpy的错误,导致无法继续安装tensorflow,使用以下方式处理:

# pip install --ignore-installed numpy

处理完成之后重新执行# pip install tensorflow即可完成安装。

3.测试tensorflow:

>>> import tensorflow as tf

>>> hello = tf.constant('Hello,Tensorflow!')

>>> sess = tf.Session()

2018-06-26 09:41:38.033305: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

>>> print sess.run(hello)

Hello,Tensorflow!

>>> a = tf.constant(10)

>>> b = tf.constant(32)

>>> print sess.run(a+b)

42

 

 

CentOS7.4中使用virtualenv虚拟环境单间python3.6的tensorflow环境步骤:

1.安装virtualenv

# pip3 install virtualenv

2.创建python3.6虚拟环境

# virtualenv --no-site-packages /data/venv3

3.使用python3.6替换vnev3虚拟环境中的python2.7版本

# rm -f /data/vnev3/bin/python*

# ln -s ln -s /usr/bin/python3.6 python

4.进入虚拟环境验证python3.6环境

# source /data/venv3/bin/activate

注意:进入虚拟环境之后,命令行前面会出现虚拟环境的标识,在这个环境下所有python的操作和pip3的安装都是独立于其他环境的,也不会影响其他python环境,这是一个独立的虚拟空间。如下:

(venv3) [root@maizi bin]# python

Python 3.6.3 (default, Jan  4 2018, 16:40:53)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> exit()

此时,python3.6的虚拟环境创建完成。

4.安装tensorflow,因为原来已经安装了python2.7版本的tensorflow,所以需要处理一下才能继续安装python3.6版本的tensorflow,做如下处理:

# python -m ensurepip

# pip3 install tensorflow

5.验证python3.6环境的tensorflow

(venv3) [root@maizi bin]# python

Python 3.6.3 (default, Jan  4 2018, 16:40:53)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import tensorflow as tf

>>> hello = tf.constant('Hello,Tensorflow!')

>>> sess = tf.Session()

2018-06-26 10:15:50.638557: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

>>> print(sess.run(hello))

b'Hello,Tensorflow!'

>>> a = tf.constant(10)

>>> b = tf.constant(32)

>>> print(sess.run(a+b))

42

7.退出虚拟环境

(venv3) [root@maizi bin]# deactivate

[root@maizi bin]#

8.如第7步所示,没有(venv3)标识说明已经退出了python3.6的虚拟环境,此时使用的python的2.7版本的了。两个版本之间互相不干扰。

 

 

:

python3.6版本的tensorflow安装

:

:

python3.6的需要进入虚拟环境下

:

进入虚拟环境:

[root@maizi bin]# source /data/venv3/bin/activate

退出虚拟环境:

(venv3) [root@maizi bin]# deactivate

[root@maizi bin]#

:

单间-->搭建

posted on 2018-06-26 11:46  麦子9  阅读(76)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3