首页 > 学院 > 开发设计 > 正文

【tensorflow学习笔记】(2)linux下安装tensorflow

2019-11-08 02:39:08
字体:
来源:转载
供稿:网友


可以使用提供的 Pip, Docker, Virtualenv, Anaconda 或 源码编译的方法安装 TensorFlow.

我是在Ubuntu16的系统下使用pip安装的,python2.7,安装的事tensorflow1.0,以下实例演示简单叙述一下。

首先,Pip安装

<a href="https://en.wikipedia.org/wiki/Pip_(package_manager)" rel="nofollow" "="">Pip 是一个 Python 的软件包安装与管理工具.

python2.7版本

# Ubuntu/linux 64-bit$ sudo apt-get install python-pip python-dev

python3.x版本

# Ubuntu/Linux 64-bit$ sudo apt-get install python-pip3 python-dev

接着,tensorflow安装

# Ubuntu/Linux 64-bit, CPU only, Python 2.7:$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_gpu-1.0.0-cp27-cp27mu-manylinux1_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7. Requires CUDA toolkit 8.0 and CuDNN v5.# For other versions, see "Install from sources" below.$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.0-cp27-cp27mu-manylinux1_x86_64.whl

这一步需要翻墙,否则会报错

还有一种办法:

$ sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow

或者

$ sudo pip install -i http://pypi.douban.com/simple tensorflow

记者加sudo权限,否则会报错

最后,测试tensorflow安装是否成功打开终端

$ python>>> import tensorflow as tf>>> hello = tf.constant('Hello, TensorFlow!')>>> sess = tf.session()>>> PRint sess.run(hello)Hello, TensorFlow!>>> a = tf.constant(10)>>> b = tf.constant(32)>>> print sess.run(a+b)42>>>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表