Ubuntu:Installing TensorFlow from Sources(CPU Only)

来源:互联网 发布:php网页联机游戏源码 编辑:程序博客网 时间:2024/06/01 08:15

环境说明

系统:Ubuntu-17.04-desktop-amd64
版本:Python3.5

1.Clone the TensorFlow repository

To clone the latest TensorFlow repository

$ git clone https://github.com/tensorflow/tensorflow

Optionally build a specific branch(such as a release branch)

$ cd tensorflow$ git checkout Branch # where Branch is the desired branch

For example,to work with the r1.0 release instead of the master release

$ git checkout r1.0

2.Install Bazel

1.Install JDK 8

$ sudo apt-get install openjdk-8-jdk

2.Add Bazel distribution URI as a package source

$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -

3.Install and update Bazel

$ sudo apt-get update$ sudo apt-get install bazel$ sudo apt-get upgrade bazel

3.Install TensorFlow Python dependencies

To install TensorFlow,you must install the following packages:

  • Numpy,which is a numerical processing package that TensorFlow requires .
  • dev,which enables adding extensions to Python
  • pip,which enables you to install and manage certain Python packages.
  • wheel,which enables you to manage Python compressed packages in the wheel(.whl) format.
$ sudo apt-get install python3-numpy python3-dev python3-pip python3-wheel 

4.Configure the installation

$ cd tensorflow$ ./configure

配置除一下列举处,一律回车

Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3.5Please input the desired Python library path to use.  [Default is /usr/lib/python3.5/dist-packages]: /usr/local/lib/python3.5/dist-packages

5.Build the pip package

$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

6.Install the pip package

The filename of the .whl file depends on your platform.

$ sudo pip3 install /tmp/tensorflow_pkg/*.whl

TensorFlow历尽千辛万苦终于通过源码安装完毕.可以开始我们的”HelloWorld“检查一下.

原创粉丝点击