blob: c03a1d7407fe2ec176ba176037c00c7692909ec2 [file] [log] [blame]
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +05301FROM ubuntu:16.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# Install Cross-compiling ToolChain
73RUN apt-get update && apt-get install -y crossbuild-essential-arm64
74
75# Build and install Google's Protobuf library
76# Download and Extract
77RUN mkdir -p $HOME/google && \
78 cd $HOME/google && \
Keith Mok34b9aba2021-03-18 21:42:16 -070079 wget https://github.com/protocolbuffers/protobuf/releases/download/v3.12.0/protobuf-all-3.12.0.tar.gz && \
80 tar -zxvf protobuf-all-3.12.0.tar.gz
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +053081
82# Build a native (x86_64) version
Keith Mok34b9aba2021-03-18 21:42:16 -070083RUN cd $HOME/google/protobuf-3.12.0 && \
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +053084 mkdir x86_build && cd x86_build && \
85 ../configure --prefix=$HOME/armnn-devenv/google/x86_64_pb_install && \
Keith Mok34b9aba2021-03-18 21:42:16 -070086 make install -j$(nproc)
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +053087
88# Build the arm64 version of the protobuf libraries
Keith Mok34b9aba2021-03-18 21:42:16 -070089RUN cd $HOME/google/protobuf-3.12.0 && \
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +053090 mkdir arm64_build && cd arm64_build && \
91 export CC=aarch64-linux-gnu-gcc && \
92 export CXX=aarch64-linux-gnu-g++ && \
93 ../configure --host=aarch64-linux \
94 --prefix=$HOME/armnn-devenv/google/arm64_pb_install \
95 --with-protoc=$HOME/armnn-devenv/google/x86_64_pb_install/bin/protoc && \
Keith Mok34b9aba2021-03-18 21:42:16 -070096 make install -j$(nproc)
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +053097
98# Build Caffe for x86_64
99# Dep Install
100RUN apt-get update && apt-get install -y \
101 libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev \
102 --no-install-recommends libboost-all-dev \
103 libgflags-dev libgoogle-glog-dev liblmdb-dev \
104 libopenblas-dev \
105 libatlas-base-dev
106
107
Keith Mok34b9aba2021-03-18 21:42:16 -0700108# Download caffe 1.0
109RUN cd $HOME && git clone https://github.com/BVLC/caffe.git && \
110 cd caffe && git checkout eeebdab16155d34ff8f5f42137da7df4d1c7eab0
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +0530111
112# Makefile update
113# To Do: Don't copy the Local Make file to docker
114# RUN cd $HOME/caffe/ && rm Makefile.config.example
115COPY Makefile.config /tmp
116RUN mv /tmp/Makefile.config $HOME/caffe/
117
118# Dep Error - Bug ARMNN
119RUN apt-get update && apt-get install -y \
120 python-numpy
121
122# Setup Env
123# ENV PATH=$HOME/armnn-devenv/google/x86_64_pb_install/bin/:$PATH
124# ENV LD_LIBRARY_PATH=$HOME/armnn-devenv/google/x86_64_pb_install/lib/:$LD_LIBRARY_PATH
125
126# Compile CAFFE
127RUN cd $HOME/caffe/ && mkdir build && cd build && \
128 export PATH=$HOME/armnn-devenv/google/x86_64_pb_install/bin/:$PATH && \
129 export LD_LIBRARY_PATH=$HOME/armnn-devenv/google/x86_64_pb_install/lib/:$LD_LIBRARY_PATH && \
130 ldconfig && \
Keith Mok34b9aba2021-03-18 21:42:16 -0700131 cmake -DCMAKE_CXX_FLAGS=--std=c++11 ../ && \
132 make all -j$(nproc) && \
133 make test -j$(nproc) && \
134 make runtest -j$(nproc)
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +0530135
136# Build Boost library for arm64
137RUN cd $HOME && wget http://downloads.sourceforge.net/project/boost/boost/1.64.0/boost_1_64_0.tar.gz && \
138 tar xfz boost_1_64_0.tar.gz && \
139 rm boost_1_64_0.tar.gz && \
140 cd boost_1_64_0 && \
141 echo "using gcc : arm : aarch64-linux-gnu-g++ ;" > user_config.jam && \
142 ./bootstrap.sh --prefix=$HOME/armnn-devenv/boost_arm64_install && \
Keith Mok34b9aba2021-03-18 21:42:16 -0700143 ./b2 install toolset=gcc-arm link=static cxxflags=-fPIC --with-filesystem --with-test --with-log --with-program_options -j$(nproc) --user-config=user_config.jam
144
145# Download ArmNN
146RUN cd $HOME/armnn-devenv && git clone https://github.com/ARM-software/armnn.git
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +0530147
148# Build Compute Library
Keith Mok34b9aba2021-03-18 21:42:16 -0700149RUN cd $HOME/armnn-devenv/ && git clone https://review.mlplatform.org/ml/ComputeLibrary && \
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +0530150 cd ComputeLibrary && \
Keith Mok34b9aba2021-03-18 21:42:16 -0700151 git checkout $($HOME/armnn-devenv/armnn/scripts/get_compute_library.sh -p) && \
152 scons Werror=0 arch=arm64-v8a neon=1 opencl=1 embed_kernels=1 extra_cxx_flags="-fPIC" -j$(nproc) internal_only=0
153
154# Build Tensorflow 2.3.1
155RUN cd $HOME/armnn-devenv && git clone https://github.com/tensorflow/tensorflow.git && \
156 cd tensorflow && \
157 git checkout fcc4b966f1265f466e82617020af93670141b009 && \
158 ../armnn/scripts/generate_tensorflow_protobuf.sh ../tensorflow-protobuf ../google/x86_64_pb_install
159
160# Download Flatbuffer
161RUN cd $HOME/armnn-devenv && \
162 wget -O flatbuffers-1.12.0.tar.gz https://github.com/google/flatbuffers/archive/v1.12.0.tar.gz && \
163 tar xf flatbuffers-1.12.0.tar.gz && \
164 cd flatbuffers-1.12.0 && \
165 rm -f CMakeCache.txt
166
167# Build a native (x86_64) version
168RUN cd $HOME/armnn-devenv && cd flatbuffers-1.12.0 && \
169 mkdir build && \
170 cd build && \
171 cmake .. -DFLATBUFFERS_BUILD_FLATC=1 \
172 -DCMAKE_INSTALL_PREFIX:PATH=$HOME/armnn-devenv/flatbuffers \
173 -DFLATBUFFERS_BUILD_TESTS=0 && \
174 make all install -j$(nproc)
175
176# Build arm64 version of flatbuffer
177RUN cd $HOME/armnn-devenv&& cd flatbuffers-1.12.0 && \
178 mkdir build-arm64 && \
179 cd build-arm64 && \
180 CXXFLAGS="-fPIC" cmake .. -DCMAKE_C_COMPILER=/usr/bin/aarch64-linux-gnu-gcc \
181 -DCMAKE_CXX_COMPILER=/usr/bin/aarch64-linux-gnu-g++ \
182 -DFLATBUFFERS_BUILD_FLATC=1 \
183 -DCMAKE_INSTALL_PREFIX:PATH=$HOME/armnn-devenv/flatbuffers-arm64 \
184 -DFLATBUFFERS_BUILD_TESTS=0 && \
185 make all install -j$(nproc)
186
187# Build onnx
188RUN cd $HOME/armnn-devenv && git clone https://github.com/onnx/onnx.git && \
189 cd onnx && \
190 git fetch https://github.com/onnx/onnx.git 553df22c67bee5f0fe6599cff60f1afc6748c635 && git checkout FETCH_HEAD && \
191 LD_LIBRARY_PATH=$HOME/armnn-devenv/google/x86_64_pb_install/lib:$LD_LIBRARY_PATH \
192 $HOME/armnn-devenv/google/x86_64_pb_install/bin/protoc \
193 onnx/onnx.proto --proto_path=. --proto_path=../google/x86_64_pb_install/include --cpp_out $HOME/armnn-devenv/onnx
194
195# Build TfLite
196RUN cd $HOME/armnn-devenv && \
197 mkdir tflite && \
198 cd tflite && \
199 cp ../tensorflow/tensorflow/lite/schema/schema.fbs . && \
200 ../flatbuffers-1.12.0/build/flatc -c --gen-object-api --reflect-types --reflect-names schema.fbs
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +0530201
202# Build ArmNN
Keith Mok34b9aba2021-03-18 21:42:16 -0700203RUN cd $HOME/armnn-devenv && \
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +0530204 cd armnn && mkdir build && cd build && \
205 export CXX=aarch64-linux-gnu-g++ && \
206 export CC=aarch64-linux-gnu-gcc && \
207 cmake .. \
Keith Mok34b9aba2021-03-18 21:42:16 -0700208 -DCMAKE_CXX_FLAGS=-w \
209 -DBUILD_TESTS=1 \
Jegathesan Shanmugambdba2722020-03-26 22:47:37 +0530210 -DARMCOMPUTE_ROOT=$HOME/armnn-devenv/ComputeLibrary \
211 -DARMCOMPUTE_BUILD_DIR=$HOME/armnn-devenv/ComputeLibrary/build/ \
212 -DBOOST_ROOT=$HOME/armnn-devenv/boost_arm64_install/ \
213 -DARMCOMPUTENEON=1 -DARMCOMPUTECL=1 -DARMNNREF=1 \
214 -DCAFFE_GENERATED_SOURCES=$HOME/caffe/build/include \
215 -DBUILD_CAFFE_PARSER=1 \
Keith Mok34b9aba2021-03-18 21:42:16 -0700216 -DONNX_GENERATED_SOURCES=$HOME/armnn-devenv/onnx \
217 -DBUILD_ONNX_PARSER=1 \
218 -DTF_GENERATED_SOURCES=$HOME/armnn-devenv/tensorflow-protobuf \
219 -DBUILD_TF_PARSER=1 \
220 -DBUILD_TF_LITE_PARSER=1 \
221 -DTF_LITE_GENERATED_PATH=$HOME/armnn-devenv/tflite \
222 -DFLATBUFFERS_ROOT=$HOME/armnn-devenv/flatbuffers-arm64 \
223 -DFLATC_DIR=$HOME/armnn-devenv/flatbuffers-1.12.0/build \
224 -DPROTOBUF_ROOT=$HOME/armnn-devenv/google/x86_64_pb_install \
225 -DPROTOBUF_LIBRARY_DEBUG=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.23.0.0 \
226 -DPROTOBUF_LIBRARY_RELEASE=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.23.0.0 && \
227 make -j$(nproc)