Dockerfile.vx-delegate 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. # Build TensorFlow Lite VX delegate default built for x86-64 simulator
  19. WORKDIR /tmp
  20. RUN git clone https://github.com/VeriSilicon/TIM-VX.git tim-vx \
  21. && git clone https://github.com/VeriSilicon/tflite-vx-delegate.git \
  22. && git clone https://github.com/tensorflow/tensorflow.git
  23. # Build TIM-VX
  24. WORKDIR /tmp/tim-vx/host_build
  25. RUN cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../ \
  26. && make -j "$(grep -c ^processor /proc/cpuinfo)" \
  27. && make install
  28. WORKDIR /tmp/tim-vx
  29. #RUN mkdir -p prebuilt-sdk/x86_64_linux/lib/include
  30. #RUN cp prebuilt-sdk/x86_64_linux/include/CL prebuilt-sdk/x86_64_linux/lib/include -fr
  31. # Build TensorFlow Lite
  32. WORKDIR /tmp/tensorflow/build
  33. RUN cmake \
  34. -DBUILD_SHARED_LIBS=ON=on \
  35. -DTFLITE_ENABLE_RUY=on \
  36. -DTFLITE_ENABLE_NNAPI=off \
  37. -DTFLITE_ENABLE_XNNPACK=on \
  38. -DTFLITE_ENABLE_EXTERNAL_DELEGATE=on \
  39. ../tensorflow/lite/
  40. RUN make -j "$(grep -c ^processor /proc/cpuinfo)" \
  41. && make install \
  42. && cp --no-preserve=ownership -d lib*.so* /usr/local/lib \
  43. && cp -r --no-preserve=ownership -d flatbuffers/include/flatbuffers /usr/local/include
  44. # install header files
  45. RUN install -d /usr/local/include/tensorflow/lite
  46. WORKDIR /tmp/tensorflow/tensorflow/lite
  47. # hadolint ignore=SC2046
  48. RUN cp --parents \
  49. $(find . -name "*.h*") \
  50. /usr/local/include/tensorflow/lite
  51. # install version.h from core
  52. RUN install -d /usr/local/include/tensorflow/core/public && \
  53. cp /tmp/tensorflow/tensorflow/core/public/version.h /usr/local/include/tensorflow/core/public
  54. # Build Vx Delegate default built for x86-64 simulator
  55. WORKDIR /tmp/tflite-vx-delegate/build
  56. RUN cmake \
  57. -DBUILD_SHARED_LIBS=ON \
  58. -DFETCHCONTENT_SOURCE_DIR_TENSORFLOW=/tmp/tensorflow \
  59. -DTFLITE_LIB_LOC=/usr/local/lib/libtensorflow-lite.so \
  60. -DTIM_VX_INSTALL=/usr/local \
  61. -DCMAKE_INSTALL_PREFIX=/usr/ \
  62. ../
  63. RUN make vx_delegate -j "$(grep -c ^processor /proc/cpuinfo)" \
  64. && make install \
  65. && cp --no-preserve=ownership -d lib*.so* /usr/lib
  66. # install header files
  67. RUN install -d /usr/local/include/tensorflow-lite-vx-delegate
  68. WORKDIR /tmp/tflite-vx-delegate/
  69. # hadolint ignore=SC2046
  70. RUN cp --parents \
  71. $(find . -name "*.h*") \
  72. /usr/local/include/tensorflow-lite-vx-delegate
  73. ENV VIVANTE_SDK_DIR=/tmp/tim-vx/prebuilt-sdk/x86_64_linux/
  74. ENV VSIMULATOR_CONFIG=czl
  75. 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
  76. # Build WASI-NN
  77. WORKDIR /home/wamr
  78. COPY . .
  79. WORKDIR /home/wamr/core/iwasm/libraries/wasi-nn/test/build
  80. # hadolint ignore=SC2086
  81. RUN cmake \
  82. -DCMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}:/usr/local/lib/ \
  83. -DCMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}:/usr/local/include/ \
  84. -DWAMR_BUILD_WASI_NN=1 \
  85. -DWAMR_BUILD_WASI_NN_ENABLE_EXT=1 \
  86. -DWASI_NN_EXT_DELEGATE_PATH="/usr/lib/libvx_delegate.so" \
  87. ..
  88. RUN make -j "$(grep -c ^processor /proc/cpuinfo)"
  89. RUN cp /home/wamr/core/iwasm/libraries/wasi-nn/test/build/iwasm /run/iwasm
  90. ENTRYPOINT [ "/run/iwasm" ]