本文基于深度学习基础平台环境,搭建深度学习基础平台请参考深度学习:Ubuntu16.04+双TitanX+CUDA8.0+CUDNN5.1。官方提供了多种安装方式,这里推荐使用PIP安装方式,简单快速,如果PIP官方源太慢,可更改为国内镜像源,参考解决Python pip官方源安装缓慢、出错:
要求
Requirements
The TensorFlow Python API supports Python 2.7 and Python 3.3+.
The GPU version works best with Cuda Toolkit 8.0 and cuDNN v5.1. Other versions are supported (Cuda toolkit >= 7.0 and cuDNN >= v3) only when installing from sources.
安装
sudo apt-get install python-pip python-dev
For installing the version with GPU support, please use:
sudo pip install tensorflow-gpu
测试
$ python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> sess.run(hello)
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> sess.run(a+b)
42
>>>
是不是很简单,更过安装方式请参考Tensorflow官方之南
网友评论