Skip to content

Instantly share code, notes, and snippets.

@lextoumbourou
Created December 6, 2017 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lextoumbourou/80dae75f8ff570fa6e2d71bb715d500c to your computer and use it in GitHub Desktop.
Save lextoumbourou/80dae75f8ff570fa6e2d71bb715d500c to your computer and use it in GitHub Desktop.
Compile Tensorflow for Lambda
BASE_PATH=./
yum install -y wget
wget https://copr.fedorainfracloud.org/coprs/vbatts/bazel/repo/epel-7/vbatts-bazel-epel-7.repo -O /etc/yum.repos.d/vbatts-bazel-epel-7.repo
# Appear to have to run this twice to get it to run reliably.
yum install -y bazel; yum install -y bazel
if [ ! -d "$BASE_PATH/env" ]; then
virtualenv -p python "$BASE_PATH/env"
fi
source $BASE_PATH/env/bin/activate
if [ ! -d "$BASE_PATH/_build" ]; then
mkdir "$BASE_PATH/_build"
fi
cd _build
if [ ! -d "tensorflow" ]; then
git clone https://github.com/tensorflow/tensorflow
fi
cd tensorflow
git reset --hard v1.4.0
PYTHON_BIN_PATH=$BASE_PATH/env/bin/python CC_OPT_FLAGS="-msse4.2 -msse4.1 -mavx" \
TF_NEED_JEMALLOC=1 TF_NEED_GCP=0 TF_NEED_HDFS=0 TF_ENABLE_XLA=0 \
TF_NEED_OPENCL=0 TF_NEED_CUDA=0 TF_NEED_VERBS=0 TF_NEED_GDR=0 TF_NEED_S3=0 TF_NEED_MPI=0 \
PYTHON_LIB_PATH="$BASE_PATH/env/lib64/python3.6/site-packages" ./configure
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package --local_resources 2048,.5,1.0
bazel-bin/tensorflow/tools/pip_package/build_pip_package $BASE_PATH/_build/tensorflow_pkg
cd $BASE_PATH
pip install --upgrade $BASE_PATH/_build/tensorflow_pkg/tensorflow-*.whl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment