From 34b9aba8fb89ec6874d3d72555714955db9c1b72 Mon Sep 17 00:00:00 2001 From: Keith Mok Date: Thu, 18 Mar 2021 21:42:16 -0700 Subject: Update x86_64 DockerFile for armnn Fix break for DockerFile Signed-off-by: Keith Mok Change-Id: I0c0b10fa212583b8861301fb9e1e926237b7867d --- docker/x86_64/Dockerfile | 103 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 83 insertions(+), 20 deletions(-) (limited to 'docker') diff --git a/docker/x86_64/Dockerfile b/docker/x86_64/Dockerfile index f96181502f..c03a1d7407 100644 --- a/docker/x86_64/Dockerfile +++ b/docker/x86_64/Dockerfile @@ -76,24 +76,24 @@ RUN apt-get update && apt-get install -y crossbuild-essential-arm64 # Download and Extract RUN mkdir -p $HOME/google && \ cd $HOME/google && \ - wget https://github.com/protocolbuffers/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.tar.gz && \ - tar -zxvf protobuf-all-3.5.1.tar.gz + wget https://github.com/protocolbuffers/protobuf/releases/download/v3.12.0/protobuf-all-3.12.0.tar.gz && \ + tar -zxvf protobuf-all-3.12.0.tar.gz # Build a native (x86_64) version -RUN cd $HOME/google/protobuf-3.5.1 && \ +RUN cd $HOME/google/protobuf-3.12.0 && \ mkdir x86_build && cd x86_build && \ ../configure --prefix=$HOME/armnn-devenv/google/x86_64_pb_install && \ - make install -j16 + make install -j$(nproc) # Build the arm64 version of the protobuf libraries -RUN cd $HOME/google/protobuf-3.5.1 && \ +RUN cd $HOME/google/protobuf-3.12.0 && \ mkdir arm64_build && cd arm64_build && \ export CC=aarch64-linux-gnu-gcc && \ export CXX=aarch64-linux-gnu-g++ && \ ../configure --host=aarch64-linux \ --prefix=$HOME/armnn-devenv/google/arm64_pb_install \ --with-protoc=$HOME/armnn-devenv/google/x86_64_pb_install/bin/protoc && \ - make install -j16 + make install -j$(nproc) # Build Caffe for x86_64 # Dep Install @@ -105,8 +105,9 @@ RUN apt-get update && apt-get install -y \ libatlas-base-dev -# Download -RUN cd $HOME && git clone https://github.com/BVLC/caffe.git +# Download caffe 1.0 +RUN cd $HOME && git clone https://github.com/BVLC/caffe.git && \ + cd caffe && git checkout eeebdab16155d34ff8f5f42137da7df4d1c7eab0 # Makefile update # To Do: Don't copy the Local Make file to docker @@ -127,10 +128,10 @@ RUN cd $HOME/caffe/ && mkdir build && cd build && \ export PATH=$HOME/armnn-devenv/google/x86_64_pb_install/bin/:$PATH && \ export LD_LIBRARY_PATH=$HOME/armnn-devenv/google/x86_64_pb_install/lib/:$LD_LIBRARY_PATH && \ ldconfig && \ - cmake ../ && \ - make all -j8 && \ - make test -j8 && \ - make runtest -j8 + cmake -DCMAKE_CXX_FLAGS=--std=c++11 ../ && \ + make all -j$(nproc) && \ + make test -j$(nproc) && \ + make runtest -j$(nproc) # Build Boost library for arm64 RUN cd $HOME && wget http://downloads.sourceforge.net/project/boost/boost/1.64.0/boost_1_64_0.tar.gz && \ @@ -139,26 +140,88 @@ RUN cd $HOME && wget http://downloads.sourceforge.net/project/boost/boost/1.64.0 cd boost_1_64_0 && \ echo "using gcc : arm : aarch64-linux-gnu-g++ ;" > user_config.jam && \ ./bootstrap.sh --prefix=$HOME/armnn-devenv/boost_arm64_install && \ - ./b2 install toolset=gcc-arm link=static cxxflags=-fPIC --with-filesystem --with-test --with-log --with-program_options -j32 --user-config=user_config.jam + ./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 + +# Download ArmNN +RUN cd $HOME/armnn-devenv && git clone https://github.com/ARM-software/armnn.git # Build Compute Library -RUN cd $HOME/armnn-devenv/ && git clone https://github.com/ARM-software/ComputeLibrary.git && \ +RUN cd $HOME/armnn-devenv/ && git clone https://review.mlplatform.org/ml/ComputeLibrary && \ cd ComputeLibrary && \ - scons arch=arm64-v8a neon=1 opencl=1 embed_kernels=1 extra_cxx_flags="-fPIC" -j8 internal_only=0 + git checkout $($HOME/armnn-devenv/armnn/scripts/get_compute_library.sh -p) && \ + scons Werror=0 arch=arm64-v8a neon=1 opencl=1 embed_kernels=1 extra_cxx_flags="-fPIC" -j$(nproc) internal_only=0 + +# Build Tensorflow 2.3.1 +RUN cd $HOME/armnn-devenv && git clone https://github.com/tensorflow/tensorflow.git && \ + cd tensorflow && \ + git checkout fcc4b966f1265f466e82617020af93670141b009 && \ + ../armnn/scripts/generate_tensorflow_protobuf.sh ../tensorflow-protobuf ../google/x86_64_pb_install + +# Download Flatbuffer +RUN cd $HOME/armnn-devenv && \ + wget -O flatbuffers-1.12.0.tar.gz https://github.com/google/flatbuffers/archive/v1.12.0.tar.gz && \ + tar xf flatbuffers-1.12.0.tar.gz && \ + cd flatbuffers-1.12.0 && \ + rm -f CMakeCache.txt + +# Build a native (x86_64) version +RUN cd $HOME/armnn-devenv && cd flatbuffers-1.12.0 && \ + mkdir build && \ + cd build && \ + cmake .. -DFLATBUFFERS_BUILD_FLATC=1 \ + -DCMAKE_INSTALL_PREFIX:PATH=$HOME/armnn-devenv/flatbuffers \ + -DFLATBUFFERS_BUILD_TESTS=0 && \ + make all install -j$(nproc) + +# Build arm64 version of flatbuffer +RUN cd $HOME/armnn-devenv&& cd flatbuffers-1.12.0 && \ + mkdir build-arm64 && \ + cd build-arm64 && \ + CXXFLAGS="-fPIC" cmake .. -DCMAKE_C_COMPILER=/usr/bin/aarch64-linux-gnu-gcc \ + -DCMAKE_CXX_COMPILER=/usr/bin/aarch64-linux-gnu-g++ \ + -DFLATBUFFERS_BUILD_FLATC=1 \ + -DCMAKE_INSTALL_PREFIX:PATH=$HOME/armnn-devenv/flatbuffers-arm64 \ + -DFLATBUFFERS_BUILD_TESTS=0 && \ + make all install -j$(nproc) + +# Build onnx +RUN cd $HOME/armnn-devenv && git clone https://github.com/onnx/onnx.git && \ + cd onnx && \ + git fetch https://github.com/onnx/onnx.git 553df22c67bee5f0fe6599cff60f1afc6748c635 && git checkout FETCH_HEAD && \ + LD_LIBRARY_PATH=$HOME/armnn-devenv/google/x86_64_pb_install/lib:$LD_LIBRARY_PATH \ + $HOME/armnn-devenv/google/x86_64_pb_install/bin/protoc \ + onnx/onnx.proto --proto_path=. --proto_path=../google/x86_64_pb_install/include --cpp_out $HOME/armnn-devenv/onnx + +# Build TfLite +RUN cd $HOME/armnn-devenv && \ + mkdir tflite && \ + cd tflite && \ + cp ../tensorflow/tensorflow/lite/schema/schema.fbs . && \ + ../flatbuffers-1.12.0/build/flatc -c --gen-object-api --reflect-types --reflect-names schema.fbs # Build ArmNN -RUN cd $HOME && git clone https://github.com/ARM-software/armnn.git && \ +RUN cd $HOME/armnn-devenv && \ cd armnn && mkdir build && cd build && \ export CXX=aarch64-linux-gnu-g++ && \ export CC=aarch64-linux-gnu-gcc && \ cmake .. \ + -DCMAKE_CXX_FLAGS=-w \ + -DBUILD_TESTS=1 \ -DARMCOMPUTE_ROOT=$HOME/armnn-devenv/ComputeLibrary \ -DARMCOMPUTE_BUILD_DIR=$HOME/armnn-devenv/ComputeLibrary/build/ \ -DBOOST_ROOT=$HOME/armnn-devenv/boost_arm64_install/ \ -DARMCOMPUTENEON=1 -DARMCOMPUTECL=1 -DARMNNREF=1 \ -DCAFFE_GENERATED_SOURCES=$HOME/caffe/build/include \ -DBUILD_CAFFE_PARSER=1 \ - -DPROTOBUF_ROOT=$HOME/armnn-devenv/google/x86_64_pb_install/ \ - -DPROTOBUF_LIBRARY_DEBUG=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.15.0.1 \ - -DPROTOBUF_LIBRARY_RELEASE=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.15.0.1 && \ - make -j8 + -DONNX_GENERATED_SOURCES=$HOME/armnn-devenv/onnx \ + -DBUILD_ONNX_PARSER=1 \ + -DTF_GENERATED_SOURCES=$HOME/armnn-devenv/tensorflow-protobuf \ + -DBUILD_TF_PARSER=1 \ + -DBUILD_TF_LITE_PARSER=1 \ + -DTF_LITE_GENERATED_PATH=$HOME/armnn-devenv/tflite \ + -DFLATBUFFERS_ROOT=$HOME/armnn-devenv/flatbuffers-arm64 \ + -DFLATC_DIR=$HOME/armnn-devenv/flatbuffers-1.12.0/build \ + -DPROTOBUF_ROOT=$HOME/armnn-devenv/google/x86_64_pb_install \ + -DPROTOBUF_LIBRARY_DEBUG=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.23.0.0 \ + -DPROTOBUF_LIBRARY_RELEASE=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.23.0.0 && \ + make -j$(nproc) -- cgit v1.2.1