Last active
April 27, 2020 12:43
-
-
Save somewacko/40071531b9c66e61addd081c64fbe278 to your computer and use it in GitHub Desktop.
Script to build and install the C++ TensorFlow library to /usr/local
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# | |
# Installs the C++ headers and library for TensorFlow. | |
TF_VERSION=v1.2.1 | |
INSTALL_TARGET=/usr/local | |
if [ ! `command -v bazel` ]; then | |
echo "TensorFlow requires bazel in order to build TensorFlow!" | |
echo "Please install bazel and make sure it's on your PATH and try again." | |
exit 1 | |
fi | |
# Download TensorFlow from git if it doesn't already exist | |
if [ ! -d "tensorflow" ]; then | |
git clone https://github.com/tensorflow/tensorflow.git | |
fi | |
cd tensorflow | |
# Check out the correct version we want to use | |
git checkout $TF_VERSION | |
# Configure the TensorFlow install (requires user input!) | |
./configure | |
# Build TensorFlow (may take a while!) | |
bazel build //tensorflow:libtensorflow_cc.so | |
# Install the relevant files to /usr/local | |
if [ $? -eq 0 ]; then | |
mkdir $INSTALL_TARGET/include/tf | |
cp -r bazel-genfiles/ $INSTALL_TARGET/include/tf/ | |
cp -r tensorflow $INSTALL_TARGET/include/tf/ | |
cp -r third_party $INSTALL_TARGET/include/tf/ | |
cp -r bazel-bin/tensorflow/libtensorflow_cc.so $INSTALL_TARGET/lib/ | |
else | |
echo "TensorFlow could not be built, not installing..." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment