首页 > 代码库 > Ubuntu安装TensorFlow

Ubuntu安装TensorFlow

参考网站:

[1] Tensorflow官网Tutorials 
[2] 
极客学院对Tensorflow官网教程的翻译

[3] CSDN-Ubuntu下如何安装TensorFlow

http://blog.csdn.net/zhaoyu106/article/details/52793183 [CSDN]

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#pip-installation

https://www.tensorflow.org/versions/r0.11/get_started/os_setup#test_the_tensorflow_installation (官网教程)

http://blog.csdn.net/mydear_11000/article/details/52020835 (之前版本的tensorflow)

 

http://www.jianshu.com/p/636c6477250a (搭建Tensorflow虚拟机学习环境)

 

https://github.com/CreatCodeBuild/TensorFlow-Chinese-Tutorial (中文视频教程)

Ubuntu安装TensorFlow

  1. 源码安装(未成功)
  1. 安装bazel的依赖
  2. 安装bazel
    1. pip安装

Pip豆瓣源安装

https://www.douban.com/note/302711300/

使用镜像源很简单,用-i指定就行了:

  1. sudo easy_install -i http://pypi.douban.com/simple/ saltTesting
  2. sudo pip install -i http://pypi.douban.com/simple/ saltTesting

Pip安装

注意tensorflow的版本以及对应的CUDA库和cuDNN版本

安装 TensorFlow :

0.8.0依赖cuda7.5cudnnv4

# Ubuntu/Linux 64-bit, CPU only, Python 2.7:

$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

 

# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7. Requires CUDA toolkit 7.5 and CuDNN v4.

# For other versions, see "Install from sources" below.

$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

 

# Mac OS X, CPU only:

$ sudo easy_install --upgrade six

$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl

0.12.0依赖cuda8.0cudnnv5

The GPU version works best with Cuda Toolkit 8.0 and cuDNN v5.1. Other versions are supported.

We have also uploaded the binaries to Pypi, so you can simply install tensorflow on Linux, Mac or Windows with pip install. Note you will need pip version 8.1 or later for the following commands to work on Linux :

$ pip install tensorflow

For installing the version with GPU support, please use:

$ pip install tensorflow-gpu

环境变量(未设置)

  1. export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
  2. export CUDA_HOME=/usr/local/cuda

测试python是否安装成功

通过下面一段代码来测试tensorflow是否安装成功:

  1. $ python
  2. ...
  3. >>> import tensorflow as tf
  4. >>> hello = tf.constant(‘Hello, TensorFlow!‘)
  5. >>> sess = tf.Session()
  6. >>> print(sess.run(hello))
  7. Hello, TensorFlow!
  8. >>> a = tf.constant(10)
  9. >>> b = tf.constant(32)
  10. >>> print(sess.run(a + b))
  11. 42

技术分享

训练第一个网络

  1. $ cd models/tutorials/image/mnist
  2. $ python convolutional.py

技术分享

Ubuntu安装TensorFlow