Jegathesan Shanmugam | bdba272 | 2020-03-26 22:47:37 +0530 | [diff] [blame] | 1 | FROM ubuntu:16.04 |
| 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 && \ |
| 79 | wget https://github.com/protocolbuffers/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.tar.gz && \ |
| 80 | tar -zxvf protobuf-all-3.5.1.tar.gz |
| 81 | |
| 82 | # Build a native (x86_64) version |
| 83 | RUN cd $HOME/google/protobuf-3.5.1 && \ |
| 84 | mkdir x86_build && cd x86_build && \ |
| 85 | ../configure --prefix=$HOME/armnn-devenv/google/x86_64_pb_install && \ |
| 86 | make install -j16 |
| 87 | |
| 88 | # Build the arm64 version of the protobuf libraries |
| 89 | RUN cd $HOME/google/protobuf-3.5.1 && \ |
| 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 && \ |
| 96 | make install -j16 |
| 97 | |
| 98 | # Build Caffe for x86_64 |
| 99 | # Dep Install |
| 100 | RUN 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 | |
| 108 | # Download |
| 109 | RUN cd $HOME && git clone https://github.com/BVLC/caffe.git |
| 110 | |
| 111 | # Makefile update |
| 112 | # To Do: Don't copy the Local Make file to docker |
| 113 | # RUN cd $HOME/caffe/ && rm Makefile.config.example |
| 114 | COPY Makefile.config /tmp |
| 115 | RUN mv /tmp/Makefile.config $HOME/caffe/ |
| 116 | |
| 117 | # Dep Error - Bug ARMNN |
| 118 | RUN apt-get update && apt-get install -y \ |
| 119 | python-numpy |
| 120 | |
| 121 | # Setup Env |
| 122 | # ENV PATH=$HOME/armnn-devenv/google/x86_64_pb_install/bin/:$PATH |
| 123 | # ENV LD_LIBRARY_PATH=$HOME/armnn-devenv/google/x86_64_pb_install/lib/:$LD_LIBRARY_PATH |
| 124 | |
| 125 | # Compile CAFFE |
| 126 | RUN cd $HOME/caffe/ && mkdir build && cd build && \ |
| 127 | export PATH=$HOME/armnn-devenv/google/x86_64_pb_install/bin/:$PATH && \ |
| 128 | export LD_LIBRARY_PATH=$HOME/armnn-devenv/google/x86_64_pb_install/lib/:$LD_LIBRARY_PATH && \ |
| 129 | ldconfig && \ |
| 130 | cmake ../ && \ |
| 131 | make all -j8 && \ |
| 132 | make test -j8 && \ |
| 133 | make runtest -j8 |
| 134 | |
| 135 | # Build Boost library for arm64 |
| 136 | RUN cd $HOME && wget http://downloads.sourceforge.net/project/boost/boost/1.64.0/boost_1_64_0.tar.gz && \ |
| 137 | tar xfz boost_1_64_0.tar.gz && \ |
| 138 | rm boost_1_64_0.tar.gz && \ |
| 139 | cd boost_1_64_0 && \ |
| 140 | echo "using gcc : arm : aarch64-linux-gnu-g++ ;" > user_config.jam && \ |
| 141 | ./bootstrap.sh --prefix=$HOME/armnn-devenv/boost_arm64_install && \ |
| 142 | ./b2 install toolset=gcc-arm link=static cxxflags=-fPIC --with-filesystem --with-test --with-log --with-program_options -j32 --user-config=user_config.jam |
| 143 | |
| 144 | # Build Compute Library |
| 145 | RUN cd $HOME/armnn-devenv/ && git clone https://github.com/ARM-software/ComputeLibrary.git && \ |
| 146 | cd ComputeLibrary && \ |
| 147 | scons arch=arm64-v8a neon=1 opencl=1 embed_kernels=1 extra_cxx_flags="-fPIC" -j8 internal_only=0 |
| 148 | |
| 149 | # Build ArmNN |
| 150 | RUN cd $HOME && git clone https://github.com/ARM-software/armnn.git && \ |
| 151 | cd armnn && mkdir build && cd build && \ |
| 152 | export CXX=aarch64-linux-gnu-g++ && \ |
| 153 | export CC=aarch64-linux-gnu-gcc && \ |
| 154 | cmake .. \ |
| 155 | -DARMCOMPUTE_ROOT=$HOME/armnn-devenv/ComputeLibrary \ |
| 156 | -DARMCOMPUTE_BUILD_DIR=$HOME/armnn-devenv/ComputeLibrary/build/ \ |
| 157 | -DBOOST_ROOT=$HOME/armnn-devenv/boost_arm64_install/ \ |
| 158 | -DARMCOMPUTENEON=1 -DARMCOMPUTECL=1 -DARMNNREF=1 \ |
| 159 | -DCAFFE_GENERATED_SOURCES=$HOME/caffe/build/include \ |
| 160 | -DBUILD_CAFFE_PARSER=1 \ |
| 161 | -DPROTOBUF_ROOT=$HOME/armnn-devenv/google/x86_64_pb_install/ \ |
| 162 | -DPROTOBUF_LIBRARY_DEBUG=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.15.0.1 \ |
| 163 | -DPROTOBUF_LIBRARY_RELEASE=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.15.0.1 && \ |
| 164 | make -j8 |