Add 64bit Docker image for Raspberry Pi #109 (PR #207)

* Inital work for raspberrypi arm64 docker container #109

* Add aarch64 docker container to build tensorflow

* Add tensorflow for aarch64

* Add docker compose for raspberrypi running on 64bit kernel
This commit is contained in:
Guy Sheffer
2020-01-19 22:30:44 +02:00
committed by Michael Mayer
parent ab369eb75e
commit 6e5be73f9c
6 changed files with 268 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
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
RUN echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends
RUN echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes
RUN echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissin
# Install dev / build dependencies
RUN apt-get update && apt-get upgrade && \
apt-get install \
ca-certificates \
build-essential \
autoconf \
automake \
libtool \
g++-4.8 \
gcc-4.8 \
libc6-dev \
zlib1g-dev \
libssl-dev \
curl \
chrpath \
pkg-config \
unzip \
zip \
make \
nano \
wget \
git \
libtool \
python3 \
python3-git \
openjdk-8-jdk
# 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/python python /usr/bin/python3.6 10
# Download Bazel & TensorFlow
WORKDIR "/home/tensorflow"
RUN wget https://github.com/tensorflow/tensorflow/archive/v1.14.0.tar.gz
RUN tar -xzf v1.14.0.tar.gz
# Install Bazel
# RUN wget https://github.com/bazelbuild/bazel/releases/download/0.24.1/bazel-0.24.1-linux-x86_64
RUN wget https://github.com/guysoft/bazel-bin/raw/master/bazel-0.24.1-aarch64
RUN mv bazel-0.24.1-aarch64 /usr/local/bin/bazel && chmod 755 /usr/local/bin/bazel
# Configure TensorFlow
WORKDIR "/home/tensorflow/tensorflow-1.14.0"
COPY ./*.sh ./
COPY ./*.diff ./
COPY ./tf_configure.bazelrc .tf_configure.bazelrc
COPY ./Makefile.aarch64 Makefile
RUN make patch

View File

@@ -0,0 +1,21 @@
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=armv8-a ./build_static.sh
archive:
rm -rf tmp
mkdir -p tmp/lib/
mkdir -p tmp/include/tensorflow/c/eager/
cp bazel-bin/tensorflow/libtensorflow.so.$(TF_VERSION) tmp/lib/libtensorflow.so
cp bazel-bin/tensorflow/libtensorflow_framework.so.$(TF_VERSION) tmp/lib/libtensorflow_framework.so
cp tensorflow/c/eager/c_api.h tmp/include/tensorflow/c/eager/
cp tensorflow/c/c_api.h tensorflow/c/c_api_experimental.h LICENSE tmp/include/tensorflow/c/
#(cd tmp && tar -czf ../libtensorflow-nvidia-jetson-nano-$(TF_VERSION).tar.gz .)
#du -h libtensorflow-nvidia-jetson-nano-$(TF_VERSION).tar.gz
guy@golem4:/tmp/photoprism/docker/tensorflow$

View File

@@ -0,0 +1,3 @@
#!/bin/bash
time bazel build --jobs 2 --config=opt //tensorflow:libtensorflow.so

View File

@@ -0,0 +1,14 @@
version: '3.6'
services:
build:
build:
context: .
dockerfile: Dockerfile.aarch64
container_name: tensorflow-build
tty: true
restart: always
volumes:
- ./out:/output