Last active
July 20, 2017 14:42
-
-
Save jaassoon/a738de8f7b31265f948f6ebcd8b1c65e to your computer and use it in GitHub Desktop.
build tensorflow 1.2.1 from source in ubuntu17.1 by bazel
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
FROM ubuntu:17.10 | |
ENV container docker | |
WORKDIR /opt | |
# ##### Configure the build for configuration. | |
ENV TF_NEED_GCP 0 | |
ENV TF_NEED_HDFS 0 | |
ENV TF_ENABLE_XLA 0 | |
ENV TF_NEED_CUDA 0 | |
ENV TF_NEED_OPENCL 0 | |
ENV TF_NEED_JEMALLOC 1 | |
ENV CC_OPT_FLAGS -march=native | |
ENV PYTHON_BIN_PATH /usr/bin/python3.5 | |
ENV PYTHON_LIB_PATH /usr/local/lib/python3.5/dist-packages | |
ENV TF_NEED_MKL 0 | |
ENV TF_NEED_VERBS 0 | |
# git v2.7.4 Python 3.5.3+ GCC 6.3.0 | |
RUN apt-get update &&\ | |
apt-get install -y python3-numpy python3-dev python3-wheel | |
RUN apt-get install -y curl python3-pip git &&\ | |
# install bazel 0.5.2 | |
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list &&\ | |
curl https://bazel.build/bazel-release.pub.gpg | apt-key add - &&\ | |
apt-get update && apt-get install -y bazel &&\ | |
apt-get -y upgrade bazel &&\ | |
# use tensor r1.2 ->1.2.1 | |
git clone -b r1.2 https://github.com/tensorflow/tensorflow /opt/ &&\ | |
./configure &&\ | |
ln /usr/bin/python3.5 /usr/bin/python &&\ | |
# can add --verbose_failures | |
bazel build --jobs 15 --local_resources 2048,0.5,1.0 --config=opt //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-1.2.1-cp35-cp35m-linux_x86_64.whl &&\ | |
apt-get remove -y curl bazel && \ | |
rm -rf /opt/* &&\ | |
rm -rf /opt/.git &&\ | |
rm -rf /tmp/* &&\ | |
rm -rf /root/.cache &&\ | |
apt autoremove -y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment