Skip to content

Instantly share code, notes, and snippets.

@csarron
Last active April 15, 2018 02:37
Show Gist options
  • Save csarron/548ffa5237e5fec1e76c1d8f15b49915 to your computer and use it in GitHub Desktop.
Save csarron/548ffa5237e5fec1e76c1d8f15b49915 to your computer and use it in GitHub Desktop.
build TensorFlow from source and test that
sudo apt install python3-numpy python3-dev python3-pip python3-wheel
bazel build -c opt --copt=-mavx2 --copt=-mfma --copt=-msse4.2 --config=cuda -k //tensorflow/tools/pip_package:build_pip_package && \
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg && \
pip3 install /tmp/tensorflow_pkg/tensorflow*.whl
pip install six numpy wheel
#Macmini6,2
bazel build -c opt --copt=-mavx --copt=-msse4.2 -k //tensorflow/tools/pip_package:build_pip_package && \
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/macm_tf_pkg
#MacBookPro12,1
bazel build -c opt --copt=-mavx2 --copt=-mfma --copt=-msse4.2 -k //tensorflow/tools/pip_package:build_pip_package && \
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/mbp_tf_pkg
#test
python -c "import tensorflow as tf;
print(tf.__version__)
# with tf.device('/gpu:0'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
with tf.Session() as sess:
print (sess.run(c))
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment