Dockerfile.vx-delegate 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. FROM ubuntu:20.04 AS base
  4. ENV DEBIAN_FRONTEND=noninteractive
  5. # hadolint ignore=DL3008
  6. RUN apt-get update && apt-get install -y \
  7. cmake build-essential git curl libssl-dev python3 --no-install-recommends \
  8. && apt-get clean -y \
  9. && rm -rf /var/lib/apt/lists/*
  10. # hadolint ignore=DL3008
  11. RUN apt-get update && apt-get install -y wget ca-certificates --no-install-recommends \
  12. && apt-get clean -y \
  13. && rm -rf /var/lib/apt/lists/* \
  14. && mkdir /usr/local/share/ca-certificates/cacert.org \
  15. && wget -qP /usr/local/share/ca-certificates/cacert.org http://www.cacert.org/certs/root.crt http://www.cacert.org/certs/class3.crt \
  16. && update-ca-certificates \
  17. && git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
  18. # need a newer cmake
  19. RUN apt-get purge -y cmake
  20. ARG CMAKE_VER=3.27.0
  21. RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-Linux-x86_64.sh \
  22. -q -O /tmp/cmake-install.sh \
  23. && chmod u+x /tmp/cmake-install.sh \
  24. && mkdir /opt/cmake-${CMAKE_VER} \
  25. && /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-${CMAKE_VER} \
  26. && rm /tmp/cmake-install.sh \
  27. && ln -s /opt/cmake-${CMAKE_VER}/bin/* /usr/local/bin
  28. # Build TensorFlow Lite VX delegate default built for x86-64 simulator
  29. WORKDIR /tmp
  30. RUN git clone https://github.com/VeriSilicon/TIM-VX.git tim-vx \
  31. && git clone https://github.com/VeriSilicon/tflite-vx-delegate.git \
  32. && git clone https://github.com/tensorflow/tensorflow.git
  33. # Build TIM-VX
  34. WORKDIR /tmp/tim-vx/host_build
  35. RUN cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../ \
  36. && make -j "$(grep -c ^processor /proc/cpuinfo)" \
  37. && make install
  38. WORKDIR /tmp/tim-vx
  39. #RUN mkdir -p prebuilt-sdk/x86_64_linux/lib/include
  40. #RUN cp prebuilt-sdk/x86_64_linux/include/CL prebuilt-sdk/x86_64_linux/lib/include -fr
  41. # Build TensorFlow Lite
  42. WORKDIR /tmp/tensorflow/build
  43. RUN cmake \
  44. -DBUILD_SHARED_LIBS=ON=on \
  45. -DTFLITE_ENABLE_RUY=on \
  46. -DTFLITE_ENABLE_NNAPI=off \
  47. -DTFLITE_ENABLE_XNNPACK=on \
  48. -DTFLITE_ENABLE_EXTERNAL_DELEGATE=on \
  49. ../tensorflow/lite/
  50. RUN make -j "$(grep -c ^processor /proc/cpuinfo)" \
  51. && make install \
  52. && cp --no-preserve=ownership -d lib*.so* /usr/local/lib \
  53. && cp -r --no-preserve=ownership -d flatbuffers/include/flatbuffers /usr/local/include
  54. # install header files
  55. RUN install -d /usr/local/include/tensorflow/lite
  56. WORKDIR /tmp/tensorflow/tensorflow/lite
  57. # hadolint ignore=SC2046
  58. RUN cp --parents \
  59. $(find . -name "*.h*") \
  60. /usr/local/include/tensorflow/lite
  61. # install version.h from core
  62. RUN install -d /usr/local/include/tensorflow/core/public && \
  63. cp /tmp/tensorflow/tensorflow/core/public/version.h /usr/local/include/tensorflow/core/public
  64. # Build Vx Delegate default built for x86-64 simulator
  65. WORKDIR /tmp/tflite-vx-delegate/build
  66. RUN cmake \
  67. -DBUILD_SHARED_LIBS=ON \
  68. -DFETCHCONTENT_SOURCE_DIR_TENSORFLOW=/tmp/tensorflow \
  69. -DTFLITE_LIB_LOC=/usr/local/lib/libtensorflow-lite.so \
  70. -DTIM_VX_INSTALL=/usr/local \
  71. -DCMAKE_INSTALL_PREFIX=/usr/ \
  72. ../
  73. RUN make vx_delegate -j "$(grep -c ^processor /proc/cpuinfo)" \
  74. && make install \
  75. && cp --no-preserve=ownership -d lib*.so* /usr/lib
  76. # install header files
  77. RUN install -d /usr/local/include/tensorflow-lite-vx-delegate
  78. WORKDIR /tmp/tflite-vx-delegate/
  79. # hadolint ignore=SC2046
  80. RUN cp --parents \
  81. $(find . -name "*.h*") \
  82. /usr/local/include/tensorflow-lite-vx-delegate
  83. ENV VIVANTE_SDK_DIR=/tmp/tim-vx/prebuilt-sdk/x86_64_linux/
  84. ENV VSIMULATOR_CONFIG=czl
  85. ENV LD_LIBRARY_PATH=/tmp/tim-vx/prebuilt-sdk/x86_64_linux/lib:/usr/local/lib:/lib/x86_64-linux-gnu/:/lib64/:/usr/lib:$LD_LIBRARY_PATH
  86. # Build WASI-NN
  87. WORKDIR /home/wamr
  88. COPY . .
  89. WORKDIR /home/wamr/core/iwasm/libraries/wasi-nn/test/build
  90. # hadolint ignore=SC2086
  91. RUN cmake \
  92. -DCMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}:/usr/local/lib/ \
  93. -DCMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}:/usr/local/include/ \
  94. -DWAMR_BUILD_WASI_NN=1 \
  95. -DWAMR_BUILD_WASI_NN_TFLITE=1\
  96. -DWAMR_BUILD_WASI_NN_ENABLE_EXT=1 \
  97. -DWASI_NN_EXT_DELEGATE_PATH="/usr/lib/libvx_delegate.so" \
  98. ..
  99. RUN make -j "$(grep -c ^processor /proc/cpuinfo)"
  100. RUN cp /home/wamr/core/iwasm/libraries/wasi-nn/test/build/iwasm /run/iwasm \
  101. && cp /home/wamr/product-mini/platforms/linux/build/lib*.so /usr/lib
  102. ENTRYPOINT [ "/run/iwasm" ]