Skip to content

Instantly share code, notes, and snippets.

@DmitryBe
Last active February 23, 2017 03:59
Show Gist options
  • Save DmitryBe/f809457c93b0d2f46b27c14ae9dc95f9 to your computer and use it in GitHub Desktop.
Save DmitryBe/f809457c93b0d2f46b27c14ae9dc95f9 to your computer and use it in GitHub Desktop.
build tensor flow with bazel
# install dependencies
sudo apt-get install python-pip python-dev
pip install --upgrade pip
sudo apt-get install openjdk-8-jdk git python-dev python3-dev python-numpy python3-numpy build-essential python-pip python3-pip python-virtualenv swig python-wheel libcurl3-dev
# 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
# clone tensorflow
cd /tmp
git clone https://github.com/tensorflow/tensorflow
cd /tensorflow
# cofig tensorflow
./configure
# use '/usr/bin/python' for python or '/usr/bin/python3' for python3
# python packages '/usr/local/lib/python2.7/dist-packages' or '/usr/local/lib/python3.5/dist-packages/'
# build
# build with support instruction set msse4.2 (https://en.wikipedia.org/wiki/SSE4)
bazel build -c opt --copt=-mavx2 --copt=-mfma --copt=-msse4.1 --copt=-msse4.2 tensorflow/tools/pip_package:build_pip_package
# for gpu support: --config=cuda
# note: use bazel clean (before rebuild)
# build pip package (tensorflow-*.whl)
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
# install && test using virtualenv
cd /tmp && mkdir tf_test && cd tf_test
virtualenv env && pip install /tmp/tensorflow_pkg/*.whl && pip install ipython
ipython
`
import tensorflow as tf
sess = tf.InteractiveSession()
hello_op = tf.constant('hello')
sess.run(hello_op)
sess.close()
`
more:
https://alliseesolutions.wordpress.com/2016/09/08/install-gpu-tensorflow-from-sources-w-ubuntu-16-04-and-cuda-8-0-rc/
http://www.nvidia.com/object/gpu-accelerated-applications-tensorflow-installation.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment