James Conroy | 3c6e9ed | 2021-11-24 15:17:49 +0000 | [diff] [blame^] | 1 | FROM ubuntu:18.04 |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 2 | ENV TERM linux |
| 3 | ENV 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 |
| 11 | RUN 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. |
| 14 | RUN locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 |
| 15 | ENV LANG en_US.UTF-8 |
| 16 | ENV LC_ALL en_US.UTF-8 |
| 17 | |
| 18 | # Again, off the certificare |
| 19 | RUN echo "check_certificate = off" >> ~/.wgetrc |
| 20 | RUN echo "[global] \n\ |
| 21 | trusted-host = pypi.python.org \n \ |
| 22 | \t pypi.org \n \ |
| 23 | \t files.pythonhosted.org" >> /etc/pip.conf |
| 24 | |
| 25 | # Get basic packages |
| 26 | RUN 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 |
| 73 | RUN apt-get update && apt-get install -y crossbuild-essential-arm64 |
| 74 | |
| 75 | # Build and install Google's Protobuf library |
| 76 | # Download and Extract |
| 77 | RUN mkdir -p $HOME/google && \ |
| 78 | cd $HOME/google && \ |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 79 | 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 Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 81 | |
| 82 | # Build a native (x86_64) version |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 83 | RUN cd $HOME/google/protobuf-3.12.0 && \ |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 84 | mkdir x86_build && cd x86_build && \ |
| 85 | ../configure --prefix=$HOME/armnn-devenv/google/x86_64_pb_install && \ |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 86 | make install -j$(nproc) |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 87 | |
| 88 | # Build the arm64 version of the protobuf libraries |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 89 | RUN cd $HOME/google/protobuf-3.12.0 && \ |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 90 | 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 Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 96 | make install -j$(nproc) |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 97 | |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 98 | # Dep Error - Bug ARMNN |
| 99 | RUN apt-get update && apt-get install -y \ |
| 100 | python-numpy |
| 101 | |
| 102 | # Setup Env |
| 103 | # ENV PATH=$HOME/armnn-devenv/google/x86_64_pb_install/bin/:$PATH |
| 104 | # ENV LD_LIBRARY_PATH=$HOME/armnn-devenv/google/x86_64_pb_install/lib/:$LD_LIBRARY_PATH |
| 105 | |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 106 | # Download ArmNN |
James Conroy | 3c6e9ed | 2021-11-24 15:17:49 +0000 | [diff] [blame^] | 107 | RUN cd $HOME/armnn-devenv && git clone "https://review.mlplatform.org/ml/armnn" && \ |
| 108 | cd armnn && git checkout remotes/origin/branches/armnn_21_11 |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 109 | |
| 110 | # Build Compute Library |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 111 | RUN cd $HOME/armnn-devenv/ && git clone https://review.mlplatform.org/ml/ComputeLibrary && \ |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 112 | cd ComputeLibrary && \ |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 113 | git checkout $($HOME/armnn-devenv/armnn/scripts/get_compute_library.sh -p) && \ |
| 114 | scons Werror=0 arch=arm64-v8a neon=1 opencl=1 embed_kernels=1 extra_cxx_flags="-fPIC" -j$(nproc) internal_only=0 |
| 115 | |
Keith Davis | 446814b | 2021-10-21 12:24:11 +0100 | [diff] [blame] | 116 | # Build Tensorflow 2.5.1 |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 117 | RUN cd $HOME/armnn-devenv && git clone https://github.com/tensorflow/tensorflow.git && \ |
| 118 | cd tensorflow && \ |
Keith Davis | 446814b | 2021-10-21 12:24:11 +0100 | [diff] [blame] | 119 | git checkout a4dfb8d1a71385bd6d122e4f27f86dcebb96712d && \ |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 120 | ../armnn/scripts/generate_tensorflow_protobuf.sh ../tensorflow-protobuf ../google/x86_64_pb_install |
| 121 | |
| 122 | # Download Flatbuffer |
| 123 | RUN cd $HOME/armnn-devenv && \ |
| 124 | wget -O flatbuffers-1.12.0.tar.gz https://github.com/google/flatbuffers/archive/v1.12.0.tar.gz && \ |
| 125 | tar xf flatbuffers-1.12.0.tar.gz && \ |
| 126 | cd flatbuffers-1.12.0 && \ |
| 127 | rm -f CMakeCache.txt |
| 128 | |
| 129 | # Build a native (x86_64) version |
| 130 | RUN cd $HOME/armnn-devenv && cd flatbuffers-1.12.0 && \ |
| 131 | mkdir build && \ |
| 132 | cd build && \ |
| 133 | cmake .. -DFLATBUFFERS_BUILD_FLATC=1 \ |
| 134 | -DCMAKE_INSTALL_PREFIX:PATH=$HOME/armnn-devenv/flatbuffers \ |
| 135 | -DFLATBUFFERS_BUILD_TESTS=0 && \ |
| 136 | make all install -j$(nproc) |
| 137 | |
| 138 | # Build arm64 version of flatbuffer |
| 139 | RUN cd $HOME/armnn-devenv&& cd flatbuffers-1.12.0 && \ |
| 140 | mkdir build-arm64 && \ |
| 141 | cd build-arm64 && \ |
| 142 | CXXFLAGS="-fPIC" cmake .. -DCMAKE_C_COMPILER=/usr/bin/aarch64-linux-gnu-gcc \ |
| 143 | -DCMAKE_CXX_COMPILER=/usr/bin/aarch64-linux-gnu-g++ \ |
| 144 | -DFLATBUFFERS_BUILD_FLATC=1 \ |
| 145 | -DCMAKE_INSTALL_PREFIX:PATH=$HOME/armnn-devenv/flatbuffers-arm64 \ |
| 146 | -DFLATBUFFERS_BUILD_TESTS=0 && \ |
| 147 | make all install -j$(nproc) |
| 148 | |
| 149 | # Build onnx |
| 150 | RUN cd $HOME/armnn-devenv && git clone https://github.com/onnx/onnx.git && \ |
| 151 | cd onnx && \ |
| 152 | git fetch https://github.com/onnx/onnx.git 553df22c67bee5f0fe6599cff60f1afc6748c635 && git checkout FETCH_HEAD && \ |
| 153 | LD_LIBRARY_PATH=$HOME/armnn-devenv/google/x86_64_pb_install/lib:$LD_LIBRARY_PATH \ |
| 154 | $HOME/armnn-devenv/google/x86_64_pb_install/bin/protoc \ |
| 155 | onnx/onnx.proto --proto_path=. --proto_path=../google/x86_64_pb_install/include --cpp_out $HOME/armnn-devenv/onnx |
| 156 | |
| 157 | # Build TfLite |
| 158 | RUN cd $HOME/armnn-devenv && \ |
| 159 | mkdir tflite && \ |
| 160 | cd tflite && \ |
| 161 | cp ../tensorflow/tensorflow/lite/schema/schema.fbs . && \ |
| 162 | ../flatbuffers-1.12.0/build/flatc -c --gen-object-api --reflect-types --reflect-names schema.fbs |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 163 | |
| 164 | # Build ArmNN |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 165 | RUN cd $HOME/armnn-devenv && \ |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 166 | cd armnn && mkdir build && cd build && \ |
| 167 | export CXX=aarch64-linux-gnu-g++ && \ |
| 168 | export CC=aarch64-linux-gnu-gcc && \ |
| 169 | cmake .. \ |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 170 | -DCMAKE_CXX_FLAGS=-w \ |
| 171 | -DBUILD_TESTS=1 \ |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 172 | -DARMCOMPUTE_ROOT=$HOME/armnn-devenv/ComputeLibrary \ |
| 173 | -DARMCOMPUTE_BUILD_DIR=$HOME/armnn-devenv/ComputeLibrary/build/ \ |
Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 174 | -DARMCOMPUTENEON=1 -DARMCOMPUTECL=1 -DARMNNREF=1 \ |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 175 | -DONNX_GENERATED_SOURCES=$HOME/armnn-devenv/onnx \ |
| 176 | -DBUILD_ONNX_PARSER=1 \ |
Keith Mok | 34b9aba | 2021-03-18 21:42:16 -0700 | [diff] [blame] | 177 | -DBUILD_TF_LITE_PARSER=1 \ |
| 178 | -DTF_LITE_GENERATED_PATH=$HOME/armnn-devenv/tflite \ |
| 179 | -DFLATBUFFERS_ROOT=$HOME/armnn-devenv/flatbuffers-arm64 \ |
| 180 | -DFLATC_DIR=$HOME/armnn-devenv/flatbuffers-1.12.0/build \ |
| 181 | -DPROTOBUF_ROOT=$HOME/armnn-devenv/google/x86_64_pb_install \ |
| 182 | -DPROTOBUF_LIBRARY_DEBUG=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.23.0.0 \ |
| 183 | -DPROTOBUF_LIBRARY_RELEASE=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.23.0.0 && \ |
| 184 | make -j$(nproc) |