Add Makefile & config to TensorFlow 1.14.0 build image #83

This commit is contained in:
Michael Mayer 2019-06-25 23:08:53 +02:00
parent 644e930575
commit 84aefc1272
6 changed files with 116 additions and 20 deletions

View file

@ -3,6 +3,7 @@ GOIMPORTS=goimports
BINARY_NAME=photoprism
DOCKER_TAG=`date -u +%Y%m%d`
TIDB_VERSION=2.1.11
TF_VERSION=1.14.0
DARKTABLE_VERSION="$(awk '$2 == "DARKTABLE_VERSION" { print $3; exit }' docker/darktable/Dockerfile)"
HASRICHGO := $(shell which richgo)
@ -99,8 +100,8 @@ docker-demo:
scripts/docker-build.sh demo $(DOCKER_TAG)
scripts/docker-push.sh demo $(DOCKER_TAG)
docker-tensorflow:
scripts/docker-build.sh tensorflow $(DOCKER_TAG)
scripts/docker-push.sh tensorflow $(DOCKER_TAG)
scripts/docker-build.sh tensorflow $(TF_VERSION)
scripts/docker-push.sh tensorflow $(TF_VERSION)
docker-darktable:
scripts/docker-build.sh darktable $(DARKTABLE_VERSION)
scripts/docker-push.sh darktable $(DARKTABLE_VERSION)

View file

@ -0,0 +1,31 @@
build --action_env PYTHON_BIN_PATH="/usr/bin/python3"
build --action_env PYTHON_LIB_PATH="/usr/lib/python3/dist-packages"
build --python_path="/usr/bin/python3"
build --action_env TF_NEED_OPENCL_SYCL="0"
build --action_env TF_NEED_ROCM="0"
build --action_env TF_NEED_CUDA="0"
build --action_env TF_NEED_TENSORRT="0"
build --action_env CUDA_TOOLKIT_PATH="/usr/local/cuda"
build --action_env TF_CUDA_COMPUTE_CAPABILITIES="5.3"
build --action_env TF_CUDA_CLANG="0"
build --action_env TF_CUDA_VERSION="10"
build --action_env GCC_HOST_COMPILER_PATH="/usr/bin/gcc-4.8"
build --verbose_failures
build:opt --copt=-march=core-avx-i
build:opt --copt=-Wno-sign-compare
build:opt --conlyopt=-std=c11
# build:opt --conlyopt=-D_XOPEN_SOURCE=600
build:opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
build:opt --host_copt=-march=core-avx-i
build:opt --host_conlyopt=-std=c11
# build:opt --host_conlyopt=-D_XOPEN_SOURCE=600
build:opt --host_cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
build:opt --host_copt=-Wno-sign-compare
build:opt --define with_default_optimizations=true
build:v2 --define=tf_api_version=2
build:xla --define with_xla_support=true
test --flaky_test_attempts=3
test --test_size_filters=small,medium
test --test_tag_filters=-benchmark-test,-no_oss,-oss_serial
test --build_tag_filters=-benchmark-test,-no_oss
build --action_env TF_CONFIGURE_IOS="0"

View file

@ -3,6 +3,8 @@ FROM ubuntu:18.04
LABEL maintainer="Michael Mayer <michael@liquidbytes.net>"
ENV DEBIAN_FRONTEND noninteractive
ENV TMP /tmp
ENV EXTRA_BAZEL_ARGS "--host_javabase=@local_jdk//:jdk"
# Configure apt-get
RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry
@ -32,24 +34,34 @@ RUN apt-get update && apt-get upgrade && \
make \
nano \
wget \
git
git \
libtool \
python3 \
python3-git \
openjdk-8-jdk
# Use GCC 4.8 as default compiler
# Use GCC 4.8 and Python 3 as default
# See https://www.tensorflow.org/install/source#tested_build_configurations
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.6 10
# Set up project directory
# Download Bazel & TensorFlow
WORKDIR "/home/tensorflow"
RUN wget https://github.com/tensorflow/tensorflow/archive/v1.14.0.tar.gz
RUN wget https://github.com/bazelbuild/bazel/releases/download/0.24.1/bazel-0.24.1-dist.zip
RUN tar -xzf v1.14.0.tar.gz
# Download TensorFlow
RUN wget https://github.com/tensorflow/tensorflow/archive/v1.13.1.tar.gz
RUN tar -xzf v1.13.1.tar.gz
# Build Bazel
WORKDIR "/home/tensorflow/bazel-0.24.1"
RUN unzip ../bazel-0.24.1-dist.zip
RUN bash ./compile.sh
RUN cp output/bazel /usr/local/bin/bazel
# Build TensorFlow
WORKDIR "/home/tensorflow/tensorflow-1.13.1"
COPY /docker/tensorflow/build_all_linux_arch.sh tensorflow/contrib/makefile/build_all_linux_arch.sh
RUN env JOB_COUNT=1 ARCH=core-avx-i tensorflow/contrib/makefile/build_all_linux_arch.sh
# Keep container running
CMD tail -f /dev/null
# Configure TensorFlow
WORKDIR "/home/tensorflow/tensorflow-1.14.0"
COPY /docker/tensorflow/*.sh .
COPY /docker/tensorflow/*.diff .
COPY /docker/tensorflow/.tf_configure.bazelrc .tf_configure.bazelrc
COPY /docker/tensorflow/Makefile Makefile
RUN make patch

View file

@ -0,0 +1,18 @@
TF_VERSION=1.14.0
all: libtensorflow static archive
patch:
git apply tensorflow-$(TF_VERSION).diff
libtensorflow:
bazel build --jobs 2 --config=opt //tensorflow:libtensorflow.so
static:
env JOB_COUNT=2 ARCH=core-avx-i ./build_static.sh
archive:
mkdir -p archive/lib/
mkdir -p archive/include/tensorflow/c/eager/
cp bazel-bin/tensorflow/libtensorflow.so.$(TF_VERSION) archive/lib/libtensorflow.so
cp bazel-bin/tensorflow/libtensorflow_framework.so.$(TF_VERSION) archive/lib/libtensorflow_framework.so
cp tensorflow/c/eager/c_api.h archive/include/tensorflow/c/eager/
cp tensorflow/c/c_api.h tensorflow/c/c_api_experimental.h tensorflow/c/LICENSE archive/include/tensorflow/c/
(cd archive && tar -czf ../libtensorflow-cpu-linux-core-avx-i-$(TF_VERSION).tar.gz)
du -h libtensorflow-cpu-linux-core-avx-i-$(TF_VERSION).tar.gz

View file

@ -18,9 +18,7 @@
set -e
# Make sure we're in the correct directory, at the root of the source tree.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd ${SCRIPT_DIR}/../../../
SCRIPT_DIR="tensorflow/contrib/makefile"
source "${SCRIPT_DIR}/build_helper.subr"
@ -52,4 +50,4 @@ tensorflow/contrib/makefile/compile_linux_protobuf.sh
make -j"${JOB_COUNT}" -f tensorflow/contrib/makefile/Makefile \
OPTFLAGS="-O3 -march=${ARCH}" \
HOST_CXXFLAGS="--std=c++11 -march=${ARCH}" \
MAKEFILE_DIR=${SCRIPT_DIR}
MAKEFILE_DIR="${SCRIPT_DIR}"

View file

@ -0,0 +1,36 @@
diff --git a/third_party/gif.BUILD b/third_party/gif.BUILD
index cbe730fe10..9b6881891d 100644
--- a/third_party/gif.BUILD
+++ b/third_party/gif.BUILD
@@ -20,14 +20,11 @@ cc_library(
"lib/quantize.c",
],
hdrs = ["lib/gif_lib.h"],
- defines = select({
- ":android": [
- "S_IREAD=S_IRUSR",
- "S_IWRITE=S_IWUSR",
- "S_IEXEC=S_IXUSR",
- ],
- "//conditions:default": [],
- }),
+ defines = [
+ "S_IREAD=S_IRUSR",
+ "S_IWRITE=S_IWUSR",
+ "S_IEXEC=S_IXUSR"
+ ],
includes = ["lib/."],
visibility = ["//visibility:public"],
deps = select({
diff --git a/third_party/gpus/crosstool/BUILD.tpl b/third_party/gpus/crosstool/BUILD.tpl
index f94be6de83..f16f87a2df 100644
--- a/third_party/gpus/crosstool/BUILD.tpl
+++ b/third_party/gpus/crosstool/BUILD.tpl
@@ -28,6 +28,7 @@ cc_toolchain_suite(
"darwin|compiler": ":cc-compiler-darwin",
"x64_windows|msvc-cl": ":cc-compiler-windows",
"x64_windows": ":cc-compiler-windows",
+ "aarch64": ":cc-compiler-local",
"arm": ":cc-compiler-local",
"k8": ":cc-compiler-local",
"piii": ":cc-compiler-local",