Tensorflow安装(Ubuntu Python3.5)

30 篇文章 1 订阅
23 篇文章 1 订阅

安装环境

Ubuntu 16.04.2 LTS
Python 3.5.2

选择版本

仅支持CPU版本Tensorflow
GPU版本TensorFlow

如果只是用来学习测试,建议安装第一个(CPU版本),此处用的这个版本。
产品线上就选第二个,毕竟性能更高一些,但是安装要稍微复杂一点。

安装Python环境

1.安装pip Virtualenv
$ sudo apt-get install python-pip python-dev python-virtualenv
 # for Python 2.7
$ sudo apt-get install python3-pip python3-dev python-virtualenv 
# for Python 3.n
2.创建Virtualenv环境
$ virtualenv --system-site-packages targetDirectory 
# for Python 2.7
$ virtualenv --system-site-packages -p python3 targetDirectory 
# for Python 3.n

targetDirectory是Virtualenv环境目录,此处用~/tensorflow

3.启动Virtualenv环境
$ source ~/tensorflow/bin/activate # bash, sh, ksh, or zsh
$ source ~/tensorflow/bin/activate.csh  # csh or tcsh
(tensorflow)$ 
4. 更新保证pip≥8.1
(tensorflow)$ easy_install -U pip
5.安装tensorflow
(tensorflow)$ pip install --upgrade tensorflow
      # for Python 2.7
(tensorflow)$ pip3 install --upgrade tensorflow
     # for Python 3.n
(tensorflow)$ pip install --upgrade tensorflow-gpu
  # for Python 2.7 and GPU
(tensorflow)$ pip3 install --upgrade tensorflow-gpu
 # for Python 3.n and GPU

如果第5步安装没有问题,就可以直接跳过第6步。

6.更新tensorflow
(tensorflow)$ pip install --upgrade tfBinaryURL
   # Python 2.7
(tensorflow)$ pip3 install --upgrade tfBinaryURL
  # Python 3.n 

tfBinaryURL是Tensorflow的Python包地址,可以在这儿找到对应操作系统/Python版本/GPU的包。
如果还有问题,请访问这儿

以后步骤

每次使用TensorFlow,都要启动Virtualenv。

$ source ~/tensorflow/bin/activate      # bash, sh, ksh, or zsh
$ source ~/tensorflow/bin/activate.csh  # csh or tcsh

显示这样就表示启动了:

(tensorflow)$ 

关闭就这样:

(tensorflow)$ deactivate 

卸载TensorFlow

直接删掉virtualenv的目录就可以了:

$ rm -r targetDirectory 

参考地址

https://www.tensorflow.org/install/install_linux

本文是《TensorFlow机器学习实战指南》的读书笔记。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小龙在山东

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值