blob: a2f753ffedb1ece607431edf5ce1ca2dcc30b805 [file] [log] [blame]
Jegathesan Shanmugam0e6e8762020-03-26 22:25:32 +05301FROM ubuntu:18.04
2ENV TERM linux
3ENV DEBIAN_FRONTEND noninteractive
4
5# Forward system proxy setting
6# ARG proxy
7# ENV http_proxy $proxy
8# ENV https_proxy $proxy
9
10# Basic apt update
11RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends locales ca-certificates && rm -rf /var/lib/apt/lists/*
12
13# Set the locale to en_US.UTF-8, because the Yocto build fails without any locale set.
14RUN locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
15ENV LANG en_US.UTF-8
16ENV LC_ALL en_US.UTF-8
17
18# Again, off the certificare
19RUN echo "check_certificate = off" >> ~/.wgetrc
20RUN echo "[global] \n\
21trusted-host = pypi.python.org \n \
22\t pypi.org \n \
23\t files.pythonhosted.org" >> /etc/pip.conf
24
25# Get basic packages
26RUN apt-get update && apt-get install -y \
27 apparmor \
28 aufs-tools \
29 automake \
30 bash-completion \
31 btrfs-tools \
32 build-essential \
33 cmake \
34 createrepo \
35 curl \
36 dpkg-sig \
37 g++ \
38 gcc \
39 git \
40 iptables \
41 jq \
42 libapparmor-dev \
43 libc6-dev \
44 libcap-dev \
45 libsystemd-dev \
46 libyaml-dev \
47 mercurial \
48 net-tools \
49 parallel \
50 pkg-config \
51 python-dev \
52 python-mock \
53 python-pip \
54 python-setuptools \
55 python-websocket \
56 golang-go \
57 iproute2 \
58 iputils-ping \
59 vim-common \
60 vim \
61 wget \
62 libtool \
63 unzip \
64 scons \
65 curl \
66 autoconf \
67 libtool \
68 build-essential \
69 g++ \
70 cmake && rm -rf /var/lib/apt/lists/*
71
72# Download the Android NDK and make a standalone toolchain
73RUN mkdir -p /home/armnn-devenv/toolchains && \
74 cd /home/armnn-devenv/toolchains && \
75 wget https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip && \
76 unzip android-ndk-r17b-linux-x86_64.zip
77
78ENV NDK /home/armnn-devenv/toolchains/android-ndk-r17b
79
80RUN $NDK/build/tools/make_standalone_toolchain.py \
81 --arch arm64 \
82 --api 26 \
83 --stl=libc++ \
84 --install-dir=/home/armnn-devenv/toolchains/aarch64-android-r17b
85
86ENV PATH=/home/armnn-devenv/toolchains/aarch64-android-r17b/bin:$PATH
87
88# Build the Boost C++ libraries
89RUN mkdir /home/armnn-devenv/boost && \
90 cd /home/armnn-devenv/boost && \
91 wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.bz2 && \
92 tar xvf boost_1_64_0.tar.bz2
93
94RUN echo "using gcc : arm : aarch64-linux-android-clang++ ;" > /home/armnn-devenv/boost/user-config.jam && \
95 cd /home/armnn-devenv/boost/boost_1_64_0 && \
96 ./bootstrap.sh --prefix=/home/armnn-devenv/boost/install && \
97 ./b2 install --user-config=/home/armnn-devenv/boost/user-config.jam \
98 toolset=gcc-arm link=static cxxflags=-fPIC --with-filesystem \
99 --with-test --with-log --with-program_options -j8
100
101# Build the Compute Library
102RUN cd /home/armnn-devenv && \
103 git clone https://github.com/ARM-software/ComputeLibrary.git && \
104 cd ComputeLibrary && \
105 scons arch=arm64-v8a neon=1 opencl=1 embed_kernels=1 extra_cxx_flags="-fPIC" \
106 benchmark_tests=0 validation_tests=0 os=android -j8
107
108# RUN mkdir /home/armnn-devenv/google && \
109RUN mkdir -p /home/armnn-devenv/google && \
110 cd /home/armnn-devenv/google && \
111 git clone https://github.com/google/protobuf.git && \
112 cd protobuf && \
113 git checkout -b v3.5.2 v3.5.2 && \
114 ./autogen.sh && \
115 mkdir x86_build && \
116 cd x86_build && \
117 ../configure --prefix=/home/armnn-devenv/google/x86_pb_install && \
118 make install -j8
119
120RUN cd /home/armnn-devenv/google/protobuf && \
121 mkdir arm64_build && cd arm64_build && \
122 CC=aarch64-linux-android-clang \
123 CXX=aarch64-linux-android-clang++ \
124 CFLAGS="-fPIE -fPIC" LDFLAGS="-pie -llog" \
125 ../configure --host=aarch64-linux-android \
126 --prefix=/home/armnn-devenv/google/arm64_pb_install \
127 --with-protoc=/home/armnn-devenv/google/x86_pb_install/bin/protoc && \
128 make install -j8
129
130# clone Tensorflow
131RUN cd /home/armnn-devenv/google/ && \
132 git clone https://github.com/tensorflow/tensorflow.git
133
134# Clone ARMNN
135RUN cd /home/armnn-devenv/ && \
136 git clone https://github.com/ARM-software/armnn.git
137
138# Generate TensorFlow protobuf definitions
139RUN cd /home/armnn-devenv/google/tensorflow && \
140 git checkout a0043f9262dc1b0e7dc4bdf3a7f0ef0bebc4891e && \
141 /home/armnn-devenv/armnn/scripts/generate_tensorflow_protobuf.sh \
142 /home/armnn-devenv/google/tf_pb /home/armnn-devenv/google/x86_pb_install
143
144ENV PATH=/home/armnn-devenv/toolchains/android-ndk-r17b:$PATH
145# Build Google Flatbuffers for ARMNN TFLite Parser
146RUN cd /home/armnn-devenv/ && \
147 git clone https://github.com/google/flatbuffers.git && \
148 cd flatbuffers && \
149 cd android && cd jni && \
150 rm -rf Application.mk && \
151 echo "APP_STL := c++_static" >> Application.mk && \
152 echo "NDK_TOOLCHAIN_VERSION" := clang >> Application.mk && \
153 echo "APP_CPPFLAGS :=-std=c++11" >> Application.mk && \
154 echo "APP_ABI := arm64-v8a" >> Application.mk && \
155 echo "APP_PLATFORM := android-23" >> Application.mk && \
156 echo "NDK_PLATFORM=android-23" >> Application.mk && \
157 cd ../ && ndk-build -B
158
159COPY ./docker-entrypoint.sh /usr/bin
160RUN chmod +x /usr/bin/docker-entrypoint.sh
161ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
162
163#To do:
164# 1. Flatbuffers build Application.mk hardcode value need to fix.