Build TensorFlow v1.13.1 in Docker container #83
This commit is contained in:
parent
1b0b41b824
commit
ec518628c8
2 changed files with 103 additions and 34 deletions
|
@ -1,41 +1,55 @@
|
||||||
FROM photoprism/development:20190617
|
FROM ubuntu:18.04
|
||||||
|
|
||||||
# Install Python and TensorFlow
|
LABEL maintainer="Michael Mayer <michael@liquidbytes.net>"
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
python3 \
|
|
||||||
python-setuptools \
|
|
||||||
python3-dev \
|
|
||||||
&& \
|
|
||||||
apt-get clean && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
python get-pip.py && \
|
|
||||||
rm get-pip.py
|
|
||||||
|
|
||||||
RUN pip --no-cache-dir install --upgrade \
|
# Configure apt-get
|
||||||
tensorflow \
|
RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry
|
||||||
requests \
|
RUN echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends
|
||||||
Pillow \
|
RUN echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests
|
||||||
h5py \
|
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes
|
||||||
ipykernel \
|
RUN echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissin
|
||||||
jupyter \
|
|
||||||
keras_applications \
|
# Install dev / build dependencies
|
||||||
keras_preprocessing \
|
RUN apt-get update && apt-get upgrade && \
|
||||||
matplotlib \
|
apt-get install \
|
||||||
numpy \
|
ca-certificates \
|
||||||
pandas \
|
build-essential \
|
||||||
scipy \
|
autoconf \
|
||||||
sklearn \
|
automake \
|
||||||
&& \
|
libtool \
|
||||||
python -m ipykernel.kernelspec
|
g++-4.8 \
|
||||||
|
gcc-4.8 \
|
||||||
|
libc6-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
libssl-dev \
|
||||||
|
curl \
|
||||||
|
chrpath \
|
||||||
|
pkg-config \
|
||||||
|
unzip \
|
||||||
|
zip \
|
||||||
|
make \
|
||||||
|
nano \
|
||||||
|
wget \
|
||||||
|
git
|
||||||
|
|
||||||
|
# Use GCC 4.8 as default compiler
|
||||||
|
# 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
|
||||||
|
|
||||||
# Set up project directory
|
# Set up project directory
|
||||||
WORKDIR "/go/src/github.com/photoprism/photoprism"
|
WORKDIR "/home/tensorflow"
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Build PhotoPrism
|
# Download TensorFlow
|
||||||
RUN make all install
|
RUN wget https://github.com/tensorflow/tensorflow/archive/v1.13.1.tar.gz
|
||||||
|
RUN tar -xzf v1.13.1.tar.gz
|
||||||
|
|
||||||
# Start PhotoPrism server
|
# Build TensorFlow
|
||||||
CMD photoprism start
|
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
|
||||||
|
|
55
docker/tensorflow/build_all_linux_arch.sh
Executable file
55
docker/tensorflow/build_all_linux_arch.sh
Executable file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
# ==============================================================================
|
||||||
|
# Downloads and builds all of TensorFlow's dependencies for Linux, and compiles
|
||||||
|
# the TensorFlow library itself. Supported on Ubuntu 14.04 and 16.04.
|
||||||
|
|
||||||
|
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}/../../../
|
||||||
|
|
||||||
|
source "${SCRIPT_DIR}/build_helper.subr"
|
||||||
|
|
||||||
|
# Note: Limit the number of jobs to 1 on ARM64 to prevent the build from being killed
|
||||||
|
JOB_COUNT="${JOB_COUNT:-$(get_job_count)}"
|
||||||
|
|
||||||
|
# Set CPU architecture e.g. core-avx-i, haswell or armv8-a
|
||||||
|
# See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
|
||||||
|
# and https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html
|
||||||
|
ARCH=${ARCH:-core-avx-i}
|
||||||
|
|
||||||
|
# Remove any old files first.
|
||||||
|
make -f tensorflow/contrib/makefile/Makefile clean
|
||||||
|
rm -rf tensorflow/contrib/makefile/downloads
|
||||||
|
|
||||||
|
# Pull down the required versions of the frameworks we need.
|
||||||
|
tensorflow/contrib/makefile/download_dependencies.sh
|
||||||
|
|
||||||
|
# Compile nsync.
|
||||||
|
# Don't use export var=`something` syntax; it swallows the exit status.
|
||||||
|
HOST_NSYNC_LIB=`tensorflow/contrib/makefile/compile_nsync.sh`
|
||||||
|
TARGET_NSYNC_LIB="$HOST_NSYNC_LIB"
|
||||||
|
export HOST_NSYNC_LIB TARGET_NSYNC_LIB
|
||||||
|
|
||||||
|
# Compile protobuf.
|
||||||
|
tensorflow/contrib/makefile/compile_linux_protobuf.sh
|
||||||
|
|
||||||
|
# Build TensorFlow for ARCH.
|
||||||
|
make -j"${JOB_COUNT}" -f tensorflow/contrib/makefile/Makefile \
|
||||||
|
OPTFLAGS="-O3 -march=${ARCH}" \
|
||||||
|
HOST_CXXFLAGS="--std=c++11 -march=${ARCH}" \
|
||||||
|
MAKEFILE_DIR=${SCRIPT_DIR}
|
Loading…
Reference in a new issue