Make wasi-nn backends as separated shared libraries (#3509)
- All files under *core/iwasm/libraries/wasi-nn* are compiled as shared libraries - *wasi-nn.c* is shared between backends - Every backend has a separated shared library - If wasi-nn feature is enabled, iwasm will depend on shared library libiwasm.so instead of linking static library libvmlib.a
This commit is contained in:
@ -5,31 +5,28 @@ FROM ubuntu:20.04 AS base
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get update && apt-get install -y \
|
||||
cmake build-essential git --no-install-recommends
|
||||
# hadolint ignore=DL3008,DL3009
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends\
|
||||
ca-certificates cmake build-essential git wget
|
||||
|
||||
WORKDIR /usr/local/share/ca-certificates/cacert.org
|
||||
RUN wget -qP /usr/local/share/ca-certificates/cacert.org http://www.cacert.org/certs/root.crt http://www.cacert.org/certs/class3.crt \
|
||||
&& update-ca-certificates
|
||||
|
||||
WORKDIR /home/wamr
|
||||
|
||||
COPY . .
|
||||
RUN git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
WORKDIR /home/wamr/product-mini/platforms/linux/build
|
||||
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get install -y wget ca-certificates --no-install-recommends \
|
||||
&& mkdir /usr/local/share/ca-certificates/cacert.org \
|
||||
&& wget -qP /usr/local/share/ca-certificates/cacert.org http://www.cacert.org/certs/root.crt http://www.cacert.org/certs/class3.crt \
|
||||
&& update-ca-certificates \
|
||||
&& git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
RUN cmake \
|
||||
-DWAMR_BUILD_WASI_NN=1 \
|
||||
..
|
||||
|
||||
RUN make -j "$(grep -c ^processor /proc/cpuinfo)"
|
||||
WORKDIR /home/wamr/product-mini/platforms/linux
|
||||
RUN rm -rf build \
|
||||
&& cmake -S . -B build -DWAMR_BUILD_WASI_NN=1 \
|
||||
&& cmake --build build -j "$(grep -c ^processor /proc/cpuinfo)"
|
||||
|
||||
FROM ubuntu:22.04
|
||||
|
||||
COPY --from=base /home/wamr/product-mini/platforms/linux/build/iwasm /iwasm
|
||||
COPY --from=base /home/wamr/product-mini/platforms/linux/build/iwasm /usr/bin/iwasm
|
||||
COPY --from=base /home/wamr/product-mini/platforms/linux/build/libiwasm.so /lib/libiwasm.so
|
||||
COPY --from=base /home/wamr/product-mini/platforms/linux/build/libwasi-nn-*.so /lib/
|
||||
|
||||
ENTRYPOINT [ "/iwasm" ]
|
||||
ENTRYPOINT [ "iwasm" ]
|
||||
|
||||
@ -5,29 +5,25 @@ FROM ubuntu:20.04 AS base
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get update && apt-get install -y \
|
||||
cmake build-essential git --no-install-recommends
|
||||
# hadolint ignore=DL3008,DL3009
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends\
|
||||
ca-certificates cmake build-essential git wget
|
||||
|
||||
WORKDIR /usr/local/share/ca-certificates/cacert.org
|
||||
RUN wget -qP /usr/local/share/ca-certificates/cacert.org http://www.cacert.org/certs/root.crt http://www.cacert.org/certs/class3.crt \
|
||||
&& update-ca-certificates
|
||||
|
||||
WORKDIR /home/wamr
|
||||
|
||||
COPY . .
|
||||
RUN git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
WORKDIR /home/wamr/product-mini/platforms/linux/build
|
||||
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get install -y wget ca-certificates --no-install-recommends \
|
||||
&& mkdir /usr/local/share/ca-certificates/cacert.org \
|
||||
&& wget -qP /usr/local/share/ca-certificates/cacert.org http://www.cacert.org/certs/root.crt http://www.cacert.org/certs/class3.crt \
|
||||
&& update-ca-certificates \
|
||||
&& git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
RUN cmake \
|
||||
-DWAMR_BUILD_WASI_NN=1 \
|
||||
-DWAMR_BUILD_WASI_NN_ENABLE_GPU=1 \
|
||||
..
|
||||
|
||||
RUN make -j "$(grep -c ^processor /proc/cpuinfo)"
|
||||
RUN rm -rf build \
|
||||
&& cmake -S . -B build \
|
||||
-DWAMR_BUILD_WASI_NN=1 \
|
||||
-DWAMR_BUILD_WASI_NN_ENABLE_GPU=1 \
|
||||
&& cmake --build build -j "$(grep -c ^processor /proc/cpuinfo)"
|
||||
|
||||
FROM nvidia/cuda:11.3.0-runtime-ubuntu20.04
|
||||
|
||||
@ -44,6 +40,8 @@ RUN mkdir -p /etc/OpenCL/vendors && \
|
||||
ENV NVIDIA_VISIBLE_DEVICES=all
|
||||
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
||||
|
||||
COPY --from=base /home/wamr/product-mini/platforms/linux/build/iwasm /iwasm
|
||||
COPY --from=base /home/wamr/product-mini/platforms/linux/build/iwasm /usr/bin/iwasm
|
||||
COPY --from=base /home/wamr/product-mini/platforms/linux/build/libiwasm.so /lib/libiwasm.so
|
||||
COPY --from=base /home/wamr/product-mini/platforms/linux/build/libwasi-nn-*.so /lib/
|
||||
|
||||
ENTRYPOINT [ "/iwasm" ]
|
||||
ENTRYPOINT [ "iwasm" ]
|
||||
|
||||
@ -5,33 +5,31 @@ FROM ubuntu:20.04 AS base
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get update && apt-get install -y \
|
||||
cmake build-essential git curl gnupg --no-install-recommends && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
# hadolint ignore=DL3008,DL3009
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends\
|
||||
ca-certificates cmake build-essential git wget
|
||||
|
||||
# hadolint ignore=DL3008,DL4006
|
||||
RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list && \
|
||||
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
|
||||
apt-get update && apt-get install -y libedgetpu1-std --no-install-recommends && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /usr/local/share/ca-certificates/cacert.org
|
||||
RUN wget -qP /usr/local/share/ca-certificates/cacert.org http://www.cacert.org/certs/root.crt http://www.cacert.org/certs/class3.crt \
|
||||
&& update-ca-certificates
|
||||
|
||||
WORKDIR /home/wamr
|
||||
|
||||
COPY . .
|
||||
RUN git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
WORKDIR /home/wamr/product-mini/platforms/linux/build
|
||||
WORKDIR /home/wamr/product-mini/platforms/linux
|
||||
RUN rm -rf build \
|
||||
&& cmake -S . -B build -DWAMR_BUILD_WASI_NN=1 \
|
||||
-DWAMR_BUILD_WASI_NN=1 \
|
||||
-DWAMR_BUILD_WASI_NN_ENABLE_EXTERNAL_DELEGATE=1 \
|
||||
-DWAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH="libedgetpu.so.1.0" \
|
||||
-DWAMR_BUILD_WASI_NN_ENABLE_GPU=1 \
|
||||
&& cmake --build build -j "$(grep -c ^processor /proc/cpuinfo)"
|
||||
|
||||
RUN cmake \
|
||||
-DWAMR_BUILD_WASI_NN=1 \
|
||||
-DWAMR_BUILD_WASI_NN_ENABLE_EXTERNAL_DELEGATE=1 \
|
||||
-DWAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH="libedgetpu.so.1.0" \
|
||||
-DWAMR_BUILD_WASI_NN_ENABLE_GPU=1 \
|
||||
..
|
||||
|
||||
RUN make -j "$(grep -c ^processor /proc/cpuinfo)" && \
|
||||
cp /home/wamr/product-mini/platforms/linux/build/iwasm /iwasm
|
||||
RUN cp /home/wamr/product-mini/platforms/linux/build/iwasm /usr/bin/iwasm \
|
||||
&& cp /home/wamr/product-mini/platforms/linux/build/libiwasm.so /lib/libiwasm.so \
|
||||
&& cp /home/wamr/product-mini/platforms/linux/build/libwasi-nn-*.so /lib/
|
||||
|
||||
WORKDIR /assets
|
||||
|
||||
ENTRYPOINT [ "/iwasm" ]
|
||||
ENTRYPOINT [ "iwasm" ]
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "wasi_nn.h"
|
||||
#include "wasi_nn_types.h"
|
||||
|
||||
#define MAX_MODEL_SIZE 85000000
|
||||
#define MAX_OUTPUT_TENSOR_SIZE 1000000
|
||||
|
||||
Reference in New Issue
Block a user