Dockerfile.vx-delegate 3.1 KB

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