Installing tensorflow with CPU support only from source on Ubuntu 16.04

Refers :
https://www.tensorflow.org/install/install_sources
https://bazel.build/versions/master/docs/install.html



prepare environment for ubuntu:
  • bazel
  • tensorflow python dependencies
install bazel:
$ 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 -
$ sudo apt-get update && sudo apt-get install bazel
$ sudo apt-get upgrade bazel


install tensorflow python dependencies:
for python 2.7:
$ sudo apt-get install python-numpy python-dev python-pip python-wheel
or for python 3.n:
$ sudo apt-get install python3-numpy python3-dev python3-pip python3-wheel

clone a tensorflow repository:
$ git clone https://github.com/tensorflow/tensorflow
$ cd tensorflow
$ git checkout r1.0

configure the installation:
$cd ../
$./configure
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python2.7
Please specify optimization flags to use during compilation [Default is -march=native]:
Do you wish to use jemalloc as the malloc implementation? (Linux only) [Y/n] Y
jemalloc enabled on Linux
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] N
No Google Cloud Platform support will be enabled for TensorFlow
Do you wish to build TensorFlow with Hadoop File System support? [y/N] N
No Hadoop File System support will be enabled for TensorFlow
Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] N
No XLA JIT support will be enabled for TensorFlow
Found possible Python library paths:
  /usr/local/lib/python2.7/dist-packages
  /usr/lib/python2.7/dist-packages
Please input the desired Python library path to use.  Default is [/usr/local/lib/python2.7/dist-packages]

Using python library path: /usr/local/lib/python2.7/dist-packages
Do you wish to build TensorFlow with OpenCL support? [y/N] N
No OpenCL support will be enabled for TensorFlow
Do you wish to build TensorFlow with CUDA support? [y/N] N
No CUDA support will be enabled for TensorFlow
Configuration finished
.......................
INFO: Starting clean (this may take a while). Consider using --expunge_async if the clean takes more than several minutes.
.................
INFO: All external dependencies fetched successfully.


build the pip package:
$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
The bazel build command builds a script named build_pip_package. Running this script as follows will build a .whl file within the /tmp/tensorflow_pkg directory:
$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

install the pip package:
$sudo pip install  /tmp/tensorflow_pkg/tensorflow-1.0.1-cp27-none-linux_x86_64.whl

validate your installation:
$cd ~
$python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>>


If you see "Hello, TensorFlow!" outputed, your installation done well.
Now let's start writing tensorflow programs.
I will use tensorflow to train a mode to classify images of cats or dogs to 
let machine do the click on the cat job.





No comments:

Post a Comment

fixed: embedded-redis: Unable to run on macOS Sonoma

Issue you might see below error while trying to run embedded-redis for your testing on your macOS after you upgrade to Sonoma. java.la...