diff --git a/.commitlintrc.yml b/.commitlintrc.yml index c05bbc6..7c81c41 100644 --- a/.commitlintrc.yml +++ b/.commitlintrc.yml @@ -5,3 +5,4 @@ extends: rules: header-max-length: [1, 'always', 100] body-max-line-length: [1, 'always', 100] + footer-max-line-length: [1, 'always', 100] diff --git a/.github/workflows/docker-manylinux.yml b/.github/workflows/docker-manylinux.yml new file mode 100644 index 0000000..759ebde --- /dev/null +++ b/.github/workflows/docker-manylinux.yml @@ -0,0 +1,46 @@ +--- +name: manylinux + +on: + pull_request: + branches: [main] + paths: + - 'docker-bake.manylinux.hcl' + - 'Dockerfile.manylinux*' + - 'scripts/**' + +permissions: {} + +jobs: + bake: + strategy: + fail-fast: false + matrix: + include: + - arch: x86_64 + targets: x86_64,x86_64-plugins + host_runner: ubuntu-latest + - arch: aarch64 + targets: aarch64,aarch64-plugins + host_runner: ubuntu-24.04-arm + + name: manylinux_2_28 (${{ matrix.arch }}) + runs-on: ${{ matrix.host_runner }} + + steps: + - if: ${{ github.event_name != 'pull_request' }} + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Bake and Push + uses: docker/bake-action@v6 + with: + push: ${{ github.event_name != 'pull_request' }} + files: docker-bake.manylinux.hcl + targets: ${{ matrix.targets }} diff --git a/.github/workflows/docker-ubuntu.yml b/.github/workflows/docker-ubuntu.yml new file mode 100644 index 0000000..f77898b --- /dev/null +++ b/.github/workflows/docker-ubuntu.yml @@ -0,0 +1,46 @@ +--- +name: ubuntu + +on: + pull_request: + branches: [main] + paths: + - 'docker-bake.ubuntu.hcl' + - 'Dockerfile.ubuntu*' + - 'scripts/**' + +permissions: {} + +jobs: + bake: + strategy: + fail-fast: false + matrix: + include: + - arch: x86_64 + targets: focal,jammy,noble,cuda + host_runner: ubuntu-latest + - arch: aarch64 + targets: aarch64 + host_runner: ubuntu-24.04-arm + + name: Ubuntu (${{ matrix.arch }}) + runs-on: ${{ matrix.host_runner }} + + steps: + - if: ${{ github.event_name != 'pull_request' }} + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Bake and Push + uses: docker/bake-action@v6 + with: + push: ${{ github.event_name != 'pull_request' }} + files: docker-bake.ubuntu.hcl + targets: ${{ matrix.targets }} diff --git a/Dockerfile.manylinux_2_28-base b/Dockerfile.manylinux_2_28-base new file mode 100644 index 0000000..c7fee27 --- /dev/null +++ b/Dockerfile.manylinux_2_28-base @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# SPDX-FileCopyrightText: 2019-2024 Second State INC +ARG BASE_IMAGE="quay.io/pypa/manylinux_2_28_x86_64" +FROM ${BASE_IMAGE} + +ADD scripts/SHA256SUM.manylinux_2_28 /root/ + +# See /opt/rh/gcc-toolset-13/enable +ENV PATH=/opt/rh/gcc-toolset-13/root/usr/bin${PATH:+:${PATH}} +ENV MANPATH=/opt/rh/gcc-toolset-13/root/usr/share/man${MANPATH:+:${MANPATH}} +ENV INFOPATH=/opt/rh/gcc-toolset-13/root/usr/share/info${INFOPATH:+:${INFOPATH}} +ENV LD_LIBRARY_PATH=/opt/rh/gcc-toolset-13/root/usr/lib64:/opt/rh/gcc-toolset-13/root/usr/lib:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} +ENV PKG_CONFIG_PATH=/opt/rh/gcc-toolset-13/root/usr/lib64/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} + +ARG LLVM_TARGETS LLVM_TRIPLE + +RUN cd && (yum check-update || true) && yum install -y openssl-devel rpm-build cmake yum-utils && \ + yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo && \ + yum install -y gcc-toolset-13 && \ + export CPU=$(/opt/python/cp311-cp311/bin/python3 -c \ + 'import multiprocessing; print(multiprocessing.cpu_count())') && \ + export CFGFLAGS="--prefix=/opt/rh/gcc-toolset-13/root/usr --disable-shared --libdir=/opt/rh/gcc-toolset-13/root/usr/lib64" && \ + curl -s -L -O --remote-name-all \ + https://github.com/ninja-build/ninja/archive/refs/tags/v1.12.1.tar.gz \ + https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.5/llvm-19.1.5.src.tar.xz \ + https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.5/lld-19.1.5.src.tar.xz \ + https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.5/libunwind-19.1.5.src.tar.xz \ + https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.5/cmake-19.1.5.src.tar.xz \ + https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.5/third-party-19.1.5.src.tar.xz \ + https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.5/clang-19.1.5.src.tar.xz && \ + sha256sum -c SHA256SUM.manylinux_2_28 && \ + gzip -dc v1.12.1.tar.gz | tar -xf - && \ + xz -dc llvm-19.1.5.src.tar.xz | tar -xf - && \ + xz -dc lld-19.1.5.src.tar.xz | tar -xf - && \ + xz -dc libunwind-19.1.5.src.tar.xz | tar -xf - && \ + xz -dc cmake-19.1.5.src.tar.xz | tar -xf - && \ + xz -dc third-party-19.1.5.src.tar.xz | tar -xf - && \ + xz -dc clang-19.1.5.src.tar.xz | tar -xf - && \ + mkdir build && cd build && /opt/python/cp311-cp311/bin/python \ + ../ninja-1.12.1/configure.py --bootstrap \ + --with-python=/opt/python/cp311-cp311/bin/python && \ + cp -v ninja /opt/rh/gcc-toolset-13/root/usr/bin/ninja && cd - && rm -rf build && \ + mv -v llvm-19.1.5.src llvm && \ + mv -v lld-19.1.5.src lld && \ + mv -v libunwind-19.1.5.src libunwind && \ + mv -v cmake-19.1.5.src cmake && \ + mv -v third-party-19.1.5.src third-party && \ + mv -v clang-19.1.5.src clang && \ + cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/opt/rh/gcc-toolset-13/root/usr \ + -DPython3_ROOT_DIR=/opt/python/cp311-cp311 -DLLVM_LIBDIR_SUFFIX=64 \ + -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS}" -DLLVM_ENABLE_PROJECTS="lld;clang" \ + -DLLVM_DEFAULT_TARGET_TRIPLE="${LLVM_TRIPLE}" \ + -DBUILD_SHARED_LIBS=OFF llvm && \ + cmake --build build --target install && \ + rm -rf build && rm -rf * + +RUN yum clean all diff --git a/Dockerfile.manylinux_2_28-plugins-deps b/Dockerfile.manylinux_2_28-plugins-deps new file mode 100644 index 0000000..3362f32 --- /dev/null +++ b/Dockerfile.manylinux_2_28-plugins-deps @@ -0,0 +1,44 @@ +ARG BASE_IMAGE="wasmedge/wasmedge:manylinux_2_28_x86_64" +FROM ${BASE_IMAGE} AS base + +WORKDIR /root + +### deps for x86_64 ### +FROM base AS deps-amd64 +RUN cd && (yum check-update || true) && \ + yum install -y wget unzip zlib-devel zlib-static elfutils-libelf-devel + +COPY scripts/wasi-nn/install-pytorch.sh . +ENV PYTORCH_VERSION="2.5.1" +ENV PYTORCH_INSTALL_TO="/root" +ENV Torch_DIR="/root/libtorch" +RUN [ "/bin/bash", "install-pytorch.sh", "--disable-cxx11-abi" ] + +### deps for aarch64 ### +FROM base AS deps-arm64 +RUN cd && (yum check-update || true) && \ + yum install -y wget unzip zlib-devel zlib-static + +### deps for all ### +FROM deps-${TARGETARCH} AS final + +COPY scripts/opencvmini/install-opencvmini.sh . +ENV OPENCV_VERSION="4.8.0" +RUN [ "/bin/bash", "install-opencvmini.sh" ] + +COPY scripts/wasi-crypto/build-openssl.sh . +ENV OpenSSL_DIR="/root/openssl-1.1.1n/openssl" +RUN [ "/bin/bash", "build-openssl.sh" ] + +COPY scripts/ffmpeg/install-ffmpeg-v6.0.sh . +RUN [ "/bin/bash", "install-ffmpeg-v6.0.sh" ] +ENV PKG_CONFIG_PATH=/root/FFmpeg-n6.0/output/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} +ENV LD_LIBRARY_PATH=/root/FFmpeg-n6.0/output/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + +ENV OPENVINO_VERSION="2025.0.0" +ENV OPENVINO_YEAR="2025" + +COPY scripts/wasi-nn/install-onnxruntime.sh . +RUN [ "/bin/bash", "install-onnxruntime.sh" ] + +RUN yum clean all diff --git a/Dockerfile.ubuntu-base b/Dockerfile.ubuntu-base new file mode 100644 index 0000000..8ef2aa4 --- /dev/null +++ b/Dockerfile.ubuntu-base @@ -0,0 +1,78 @@ +ARG UBUNTU_VER=22 +FROM ubuntu:${UBUNTU_VER}.04 AS base + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y \ + curl \ + dpkg-dev \ + g++ \ + gcc \ + git \ + ninja-build \ + software-properties-common \ + wget \ + zlib1g-dev + +### deps for ubuntu 20.04 ### +FROM base AS deps-20 + +RUN curl -sSf https://apt.kitware.com/kitware-archive.sh | sh +RUN apt-get install -y cmake + +RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \ + && echo "deb http://apt.llvm.org/focal llvm-toolchain-focal-18 main" | tee /etc/apt/sources.list.d/llvm.list + +RUN apt-get install -y \ + llvm-18-dev \ + liblld-18-dev \ + libpolly-18-dev \ + clang-18 + +RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 && \ + update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100 && \ + update-alternatives --install /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-18 100 + +ENV CC=/usr/bin/clang-18 +ENV CXX=/usr/bin/clang++-18 + +### deps for ubuntu 22.04 ### +FROM base AS deps-22 + +RUN apt-get install -y cmake + +RUN apt-get install -y \ + llvm-15-dev \ + liblld-15-dev \ + clang-15 + +RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100 && \ + update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100 && \ + update-alternatives --install /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-15 100 + +ENV CC=/usr/bin/clang-15 +ENV CXX=/usr/bin/clang++-15 + +### deps for ubuntu 24.04 ### +FROM base AS deps-24 + +RUN apt-get install -y cmake + +RUN apt-get install -y \ + llvm-18-dev \ + liblld-18-dev \ + libpolly-18-dev \ + clang-18 + +RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 && \ + update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100 && \ + update-alternatives --install /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-18 100 + +ENV CC=/usr/bin/clang-18 +ENV CXX=/usr/bin/clang++-18 + +### cleanup +FROM deps-${UBUNTU_VER} AS clean-apt + +RUN rm -rf /var/lib/apt/lists/* diff --git a/Dockerfile.ubuntu-cuda b/Dockerfile.ubuntu-cuda new file mode 100644 index 0000000..f10b8b5 --- /dev/null +++ b/Dockerfile.ubuntu-cuda @@ -0,0 +1,24 @@ +ARG BASE_IMAGE=wasmedge/wasmedge:latest +FROM ${BASE_IMAGE} AS base + +WORKDIR /root + +ARG CUDA_KEYRING=cuda-keyring_1.1-1_all.deb +RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/${CUDA_KEYRING} && \ + dpkg -i ${CUDA_KEYRING} && \ + rm -f ${CUDA_KEYRING} + +ARG NVCC_VER=12-0 +RUN apt-get update && \ + apt-get install -y \ + cuda-nvcc-${NVCC_VER} \ + libcublas-dev-${NVCC_VER} \ + pkg-config \ + unzip + +ENV CXXFLAGS="-Wno-error" + +### cleanup +FROM base AS clean-apt + +RUN rm -rf /var/lib/apt/lists/* diff --git a/Dockerfile.ubuntu-env b/Dockerfile.ubuntu-env new file mode 100644 index 0000000..dde599e --- /dev/null +++ b/Dockerfile.ubuntu-env @@ -0,0 +1,15 @@ +ARG BASE_IMAGE=wasmedge/wasmedge:latest +ARG TOOLCHAIN=clang +FROM ${BASE_IMAGE} AS base + +### env for clang +FROM base AS deps-clang + +### env for gcc +FROM base AS deps-gcc + +ENV CC=/usr/bin/gcc +ENV CXX=/usr/bin/g++ + +### final +FROM deps-${TOOLCHAIN} AS final diff --git a/Dockerfile.ubuntu-plugins-deps b/Dockerfile.ubuntu-plugins-deps new file mode 100644 index 0000000..cb745fb --- /dev/null +++ b/Dockerfile.ubuntu-plugins-deps @@ -0,0 +1,93 @@ +ARG BASE_IMAGE=wasmedge/wasmedge:latest +ARG UBUNTU_VER=20 +FROM ${BASE_IMAGE} AS base + +RUN apt-get update && \ + apt-get install -y \ + cargo \ + libelf-dev \ + libomp-dev \ + libopenblas-dev \ + libssl-dev \ + pkg-config \ + unzip \ + yasm + +RUN apt-get install -y \ + libgrpc++-dev \ + libgrpc-dev \ + protobuf-compiler-grpc + +# FFmpeg 6.1 (ubuntu 24.04) +FROM base AS deps-24 + +RUN apt-get install -y \ + libavcodec-dev \ + libavdevice-dev \ + libavfilter-dev \ + libavformat-dev \ + libavutil-dev \ + libswresample-dev \ + libswscale-dev + +# FFmpeg 6.0 (ubuntu 20.04, 22.04) +FROM base AS deps-20 + +WORKDIR /usr/local + +COPY scripts/ffmpeg/install-ffmpeg-v6.0.sh . +RUN [ "/bin/bash", "install-ffmpeg-v6.0.sh" ] +ENV PKG_CONFIG_PATH=/usr/local/FFmpeg-n6.0/output/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} +ENV LD_LIBRARY_PATH=/usr/local/FFmpeg-n6.0/output/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + +FROM deps-20 AS deps-22 + +# Other dependencies +FROM deps-${UBUNTU_VER} AS deps-all + +WORKDIR /root + +COPY scripts/opencvmini/install-opencvmini.sh . +ENV OPENCV_VERSION="4.8.0" +RUN [ "/bin/bash", "install-opencvmini.sh" ] + +COPY scripts/wasi-nn/install-pytorch.sh . +ENV PYTORCH_VERSION="2.5.1" +ENV PYTORCH_INSTALL_TO="/usr/local" +ENV Torch_DIR="/usr/local/libtorch" +RUN [ "/bin/bash", "install-pytorch.sh" ] + +ARG UBUNTU_VER + +COPY scripts/wasi-nn/install-openvino.sh . +COPY scripts/wasi-nn/install-openvino-genai.sh . +ENV OPENVINO_UBUNTU_VERSION=${UBUNTU_VER} +ENV OPENVINO_VERSION="2025.0.0" +ENV OPENVINO_YEAR="2025" +ENV OPENVINOGEN_VERSION="2025.0.0.0" +ENV OPENVINOGEN_YEAR="2025.0" +ENV OPENVINOGEN_DIRNAME="openvino_genai" +RUN [ "/bin/bash", "install-openvino.sh" ] +RUN [ "/bin/bash", "install-openvino-genai.sh" ] +RUN [ "ls", "-al" ] +RUN [ "/bin/bash", "-c", "echo \"source ./openvino_genai/setupvars.sh\" >> .bashrc" ] + +COPY scripts/wasi-nn/install-onnxruntime.sh . +RUN [ "/bin/bash", "install-onnxruntime.sh" ] + +COPY scripts/wasi-nn/install-chattts.sh . +RUN [ "/bin/bash", "install-chattts.sh" ] + +### cleanup +FROM deps-all AS clean-apt + +RUN rm -f \ + install-opencvmini.sh \ + install-ffmpeg-v6.0.sh \ + install-pytorch.sh \ + install-openvino.sh \ + install-onnxruntime.sh \ + install-openvino-genai.sh \ + install-chattts.sh + +RUN rm -rf /var/lib/apt/lists/* diff --git a/docker-bake.manylinux.hcl b/docker-bake.manylinux.hcl new file mode 100644 index 0000000..48e0cbf --- /dev/null +++ b/docker-bake.manylinux.hcl @@ -0,0 +1,51 @@ +target "base" { + dockerfile = "Dockerfile.manylinux_2_28-base" + context = "." +} + +target "plugins-base" { + dockerfile = "Dockerfile.manylinux_2_28-plugins-deps" + context = "." +} + +target "x86_64" { + inherits = ["base"] + platforms = ["linux/amd64"] + tags = ["wasmedge/wasmedge:manylinux_2_28_x86_64"] + args = { + LLVM_TARGETS = "X86;BPF", + LLVM_TRIPLE = "x86_64-pc-linux-gnu" + } +} + +target "x86_64-plugins" { + inherits = ["plugins-base"] + platforms = ["linux/amd64"] + tags = ["wasmedge/wasmedge:manylinux_2_28_x86_64-plugins-deps"] + contexts = { + "wasmedge/wasmedge:manylinux_2_28_x86_64"= "target:x86_64" + } +} + +target "aarch64" { + inherits = ["base"] + platforms = ["linux/arm64"] + tags = ["wasmedge/wasmedge:manylinux_2_28_aarch64"] + args = { + BASE_IMAGE = "quay.io/pypa/manylinux_2_28_aarch64", + LLVM_TARGETS = "AArch64;BPF", + LLVM_TRIPLE = "aarch64-redhat-linux-gnu" + } +} + +target "aarch64-plugins" { + inherits = ["plugins-base"] + platforms = ["linux/arm64"] + tags = ["wasmedge/wasmedge:manylinux_2_28_aarch64-plugins-deps"] + contexts = { + "wasmedge/wasmedge:manylinux_2_28_aarch64" = "target:aarch64" + } + args = { + BASE_IMAGE = "wasmedge/wasmedge:manylinux_2_28_aarch64" + } +} diff --git a/docker-bake.ubuntu.hcl b/docker-bake.ubuntu.hcl new file mode 100644 index 0000000..d856572 --- /dev/null +++ b/docker-bake.ubuntu.hcl @@ -0,0 +1,184 @@ +group "default" { + targets = [ + "latest", + ] +} + +group "latest" { + targets = [ + "base-2404-clang", + "plugins-2404-clang", + ] +} + +group "focal" { + targets = [ + "base-2004-clang", + "base-2004-gcc", + "plugins-2004-clang", + "plugins-2004-gcc", + ] +} + +group "jammy" { + targets = [ + "base-2204-clang", + "base-2204-gcc", + "plugins-2204-clang", + "plugins-2204-gcc", + ] +} + +group "noble" { + targets = [ + "base-2404-clang", + "base-2404-gcc", + "plugins-2404-clang", + "plugins-2404-gcc", + ] +} + +group "aarch64" { + targets = [ + "base-2004-clang-aarch64", + ] +} + +function "no-dot" { + params = [ubuntu] + result = replace(ubuntu, ".", "") +} + +function "major" { + params = [ubuntu] + result = regex("^[[:digit:]]+", ubuntu) +} + +function "tags-latest" { + params = [target, ubuntu, toolchain] + result = target == "base" && ubuntu == "24.04" && toolchain == "clang" ? "latest" : "" +} + +function "tags-latest-backports" { + params = [target, ubuntu, toolchain] + result = ubuntu == "24.04" ? join("-", compact([ + "ubuntu", + "build", + toolchain, + target == "plugins" ? "plugins-deps" : "", + ])) : "" +} + +function "tags-backports" { + params = [target, ubuntu, toolchain] + result = join("-", compact([ + "ubuntu", + ubuntu, + "build", + toolchain, + target == "plugins" ? "plugins-deps" : "", + ])) +} + +function "tags-simplified" { + params = [target, ubuntu, toolchain] + result = toolchain == "clang" ? join("-", compact([ + "ubuntu", + ubuntu, + target == "plugins" ? "plugins" : "", + ])) : "" +} + +function "tags" { + params = [target, ubuntu, toolchain] + result = [for tag in compact([ + tags-latest(target, ubuntu, toolchain), + tags-latest-backports(target, ubuntu, toolchain), + tags-backports(target, ubuntu, toolchain), + tags-simplified(target, ubuntu, toolchain), + ]) : "wasmedge/wasmedge:${tag}"] +} + +target "base" { + dockerfile = "Dockerfile.ubuntu-base" + context = "." + + matrix = { + ubuntu = ["20.04", "22.04", "24.04"] + } + + name = "base-${no-dot(ubuntu)}" + tags = ["local/tmp:base-${ubuntu}"] + args = { + UBUNTU_VER = major(ubuntu) + } +} + +target "plugins" { + dockerfile = "Dockerfile.ubuntu-plugins-deps" + context = "." + + matrix = { + ubuntu = ["20.04", "22.04", "24.04"] + } + + name = "plugins-${no-dot(ubuntu)}" + contexts = { + "local/tmp:base-${ubuntu}" = "target:base-${no-dot(ubuntu)}" + } + tags = ["local/tmp:plugins-${ubuntu}"] + args = { + BASE_IMAGE = "local/tmp:base-${ubuntu}" + UBUNTU_VER = major(ubuntu) + } +} + +target "all-versions" { + matrix = { + parent = ["base", "plugins"] + ubuntu = ["20.04", "22.04", "24.04"] + toolchain = ["clang", "gcc"] + } + + dockerfile = "Dockerfile.ubuntu-env" + context = "." + + name = "${parent}-${no-dot(ubuntu)}-${toolchain}" + contexts = { + "local/tmp:${parent}-${ubuntu}" = "target:${parent}-${no-dot(ubuntu)}" + } + tags = tags(parent, ubuntu, toolchain) + args = { + BASE_IMAGE = "local/tmp:${parent}-${ubuntu}" + TOOLCHAIN = toolchain + } +} + +target "cuda" { + dockerfile = "Dockerfile.ubuntu-cuda" + context = "." + + matrix = { + cuda = ["11.3", "12.0"] + } + + name = "base-2004-gcc-cuda${major(cuda)}" + contexts = { + "wasmedge/wasmedge:ubuntu-20.04-build-gcc" = "target:base-2004-gcc" + } + tags = ["wasmedge/wasmedge:ubuntu-20.04-build-gcc-cuda${major(cuda)}"] + args = { + BASE_IMAGE = "wasmedge/wasmedge:ubuntu-20.04-build-gcc" + NVCC_VER = replace(cuda, ".", "-") + } +} + +# TODO: Refactor with multi-arch image +target "base-2004-clang-aarch64" { + inherits = ["base-2004"] + contexts = { + "local/tmp:base-2004" = "target:base-2004" + } + tags = [for tag in tags("base", "20.04", "clang") : "${tag}-aarch64"] + platforms = ["linux/arm64"] +} diff --git a/scripts/SHA256SUM.manylinux_2_28 b/scripts/SHA256SUM.manylinux_2_28 new file mode 100644 index 0000000..136490f --- /dev/null +++ b/scripts/SHA256SUM.manylinux_2_28 @@ -0,0 +1,7 @@ +e7dfc8050407b5cc564c1c1afe19517255c9229cccd886dbd5bac9b652828d85 clang-19.1.5.src.tar.xz +a08ae477571fd5e929c27d3d0d28c6168d58dd00b6354c2de3266ae0d86ad44f cmake-19.1.5.src.tar.xz +997b493fb604e5e2c5b11c765a4c42b37acf00a4d6e8a14f8108d5c1051d760f libunwind-19.1.5.src.tar.xz +f71835d49461a15c283aa9030a854abfd7c651a685d711a67158644b043f6f14 lld-19.1.5.src.tar.xz +7d71635948e4da1814ce8e15ec45399e4094a5442e86d352c96ded0f2b3171b6 llvm-19.1.5.src.tar.xz +22b352c35b034a4ab3f2b852b6a2602a4da8971abe459080450d9e3462550d1d third-party-19.1.5.src.tar.xz +821bdff48a3f683bc4bb3b6f0b5fe7b2d647cf65d52aeb63328c91a6c6df285a v1.12.1.tar.gz diff --git a/scripts/ffmpeg/install-ffmpeg-v6.0.sh b/scripts/ffmpeg/install-ffmpeg-v6.0.sh new file mode 100755 index 0000000..d02dc73 --- /dev/null +++ b/scripts/ffmpeg/install-ffmpeg-v6.0.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -e + +curl -sL https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n6.0.zip -o ffmpeg.zip + +unzip ffmpeg.zip + +mkdir -p FFmpeg-n6.0/output +cd FFmpeg-n6.0 +./configure --prefix=$(pwd)/output --enable-gpl --enable-nonfree --enable-shared --disable-static +make && make install +cd .. + +rm -rf ffmpeg.zip diff --git a/scripts/opencvmini/install-opencvmini.sh b/scripts/opencvmini/install-opencvmini.sh new file mode 100644 index 0000000..43afef9 --- /dev/null +++ b/scripts/opencvmini/install-opencvmini.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# SPDX-FileCopyrightText: 2019-2024 Second State INC +OPENCV_VERSION=${OPENCV_VERSION:-4.8.0} + +wget -O opencv.zip https://github.com/opencv/opencv/archive/refs/tags/${OPENCV_VERSION}.zip + +unzip opencv.zip +mv opencv-${OPENCV_VERSION} opencv + +mkdir -p opencv/build && cd opencv/build +# Configure +cmake -GNinja .. +# Build +cmake --build . +# Install to system +cmake --install . + +cd - && rm -rf opencv opencv.zip diff --git a/scripts/wasi-crypto/build-openssl.sh b/scripts/wasi-crypto/build-openssl.sh new file mode 100755 index 0000000..45d628b --- /dev/null +++ b/scripts/wasi-crypto/build-openssl.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# SPDX-FileCopyrightText: 2019-2024 Second State INC + +echo "Building OpenSSL for wasi-crypto..." +# Get OpenSSL source +curl -s -L -O --remote-name-all https://www.openssl.org/source/openssl-1.1.1n.tar.gz +echo "40dceb51a4f6a5275bde0e6bf20ef4b91bfc32ed57c0552e2e8e15463372b17a openssl-1.1.1n.tar.gz" | sha256sum -c +tar -xf openssl-1.1.1n.tar.gz +cd ./openssl-1.1.1n +# OpenSSL configure need newer perl +curl -s -L -O --remote-name-all https://www.cpan.org/src/5.0/perl-5.34.0.tar.gz +tar -xf perl-5.34.0.tar.gz +cd perl-5.34.0 +mkdir localperl +./Configure -des -Dprefix=$(pwd)/localperl/ +make -j +# too long! +# make test +make install +export PATH="$(pwd)/localperl/bin/:$PATH" +cd .. +# Configure by previous perl +mkdir openssl +./perl-5.34.0/localperl/bin/perl ./config --prefix=$(pwd)/openssl --openssldir=$(pwd)/openssl +make -j +make test +make install +cd .. diff --git a/scripts/wasi-nn/install-chattts.sh b/scripts/wasi-nn/install-chattts.sh new file mode 100644 index 0000000..f406d46 --- /dev/null +++ b/scripts/wasi-nn/install-chattts.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2019-2024 Second State INC + +set -e + +apt-get update +apt-get -y install python3 python3-dev + +# Use latest pip +python3 -m venv chattts_venv +source chattts_venv/bin/activate +pip install --upgrade pip + +# Install PyTorch CPU version to save space +pip --python /usr/bin/python3 install --break-system-packages --index-url https://download.pytorch.org/whl/cpu 'torch<=2.6.0' 'torchaudio<=2.6.0' +pip --python /usr/bin/python3 install --break-system-packages chattts==0.2.3 + +# Remove wheel cache +pip --python /usr/bin/python3 cache purge + +# Clean up +deactivate +rm -rf chattts_venv diff --git a/scripts/wasi-nn/install-onnxruntime.sh b/scripts/wasi-nn/install-onnxruntime.sh new file mode 100644 index 0000000..dad1fb5 --- /dev/null +++ b/scripts/wasi-nn/install-onnxruntime.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2019-2024 Second State INC + +set -e + +case "$(uname -m)" in + 'x86_64') ARCH='x64' ;; + 'aarch64') ARCH='aarch64' ;; + *) + echo 'Cannot determine architecture for onnxruntime' >&2 + exit 1 + ;; +esac + +: ${ONNXRUNTIME_VERSION:=1.14.1} + +ONNXRUNTIME_NAME="onnxruntime-linux-${ARCH}-${ONNXRUNTIME_VERSION}" +ONNXRUNTIME_TGZ="${ONNXRUNTIME_NAME}.tgz" + +curl -LO "https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/${ONNXRUNTIME_TGZ}" +tar zxf "${ONNXRUNTIME_TGZ}" +mv "${ONNXRUNTIME_NAME}/include/"* /usr/local/include/ +mv "${ONNXRUNTIME_NAME}/lib/"* /usr/local/lib/ +rm -rf "${ONNXRUNTIME_TGZ}" "${ONNXRUNTIME_NAME}" + +ldconfig diff --git a/scripts/wasi-nn/install-openvino-genai.sh b/scripts/wasi-nn/install-openvino-genai.sh new file mode 100644 index 0000000..2be3691 --- /dev/null +++ b/scripts/wasi-nn/install-openvino-genai.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# SPDX-FileCopyrightText: 2019-2024 Second State INC +set -e + +if [[ ! -v "${OPENVINOGEN_VERSION}" ]]; then + OPENVINOGEN_VERSION="2025.0.0.0" +fi +if [[ ! -v "${OPENVINOGEN_YEAR}" ]]; then + OPENVINOGEN_YEAR="2025.0" +fi +if [[ ! -v "${OPENVINOGEN_DIRNAME}" ]]; then + OPENVINOGEN_DIRNAME="openvino_genai" +fi + +if [[ ! -v "${OPENVINO_UBUNTU_VERSION}" ]]; then + source /etc/os-release + OPENVINO_UBUNTU_VERSION="${VERSION_ID::2}" +fi + +UBUNTU_VERSION="ubuntu${OPENVINO_UBUNTU_VERSION:-20}" +OPENVINOGEN_TGZ_NAME="openvino_genai_${UBUNTU_VERSION}_${OPENVINOGEN_VERSION}_x86_64" + + +echo "Installing OpenVINO GenAI with version ${OPENVINOGEN_VERSION}" +curl -L https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/${OPENVINOGEN_YEAR}/linux/${OPENVINOGEN_TGZ_NAME}.tar.gz --output ${OPENVINOGEN_TGZ_NAME}.tgz +tar -xf ${OPENVINOGEN_TGZ_NAME}.tgz +mv ${OPENVINOGEN_TGZ_NAME} $OPENVINOGEN_DIRNAME +./${OPENVINOGEN_DIRNAME}/install_dependencies/install_openvino_dependencies.sh -y + +rm ${OPENVINOGEN_TGZ_NAME}.tgz + +echo "OpenVINO GenAI installed at `pwd`/$OPENVINOGEN_DIRNAME" +echo "Please source the setupvars.sh script in the OpenVINO GenAI directory to use the OpenVINO GenAI tools." +echo "# source $PWD/$OPENVINOGEN_DIRNAME/setupvars.sh" diff --git a/scripts/wasi-nn/install-openvino.sh b/scripts/wasi-nn/install-openvino.sh new file mode 100755 index 0000000..432f1ac --- /dev/null +++ b/scripts/wasi-nn/install-openvino.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# SPDX-FileCopyrightText: 2019-2024 Second State INC +set -e + +if [[ ! -v "${OPENVINO_VERSION}" ]]; then + OPENVINO_VERSION="2025.0.0" +fi +if [[ ! -v "${OPENVINO_YEAR}" ]]; then + OPENVINO_YEAR="2025" +fi + +echo "Installing OpenVINO with version ${OPENVINO_VERSION}" +KEY_FILE=GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB +wget https://apt.repos.intel.com/intel-gpg-keys/$KEY_FILE && \ + apt-key add $KEY_FILE && \ + rm -f $KEY_FILE +UBUNTU_VERSION="ubuntu${OPENVINO_UBUNTU_VERSION:-20}" +echo "deb https://apt.repos.intel.com/openvino/$OPENVINO_YEAR ${UBUNTU_VERSION} main" | tee /etc/apt/sources.list.d/intel-openvino-$OPENVINO_YEAR.list +apt update +apt-get -y install openvino-$OPENVINO_VERSION +ldconfig diff --git a/scripts/wasi-nn/install-pytorch.sh b/scripts/wasi-nn/install-pytorch.sh new file mode 100755 index 0000000..55f77ac --- /dev/null +++ b/scripts/wasi-nn/install-pytorch.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# SPDX-FileCopyrightText: 2019-2024 Second State INC + +if [[ ! -n ${PYTORCH_VERSION} ]]; then + PYTORCH_VERSION="2.5.1" +fi + +if [[ ! -n ${PYTORCH_INSTALL_TO} ]]; then + PYTORCH_INSTALL_TO=. +fi + +PYTORCH_LINK="libtorch-cxx11-abi" +PYTORCH_SHA="618ca54eef82a1dca46ff1993d5807d9c0deb0bae147da4974166a147cb562fa" + +for i in "$@"; do + case $i in + --disable-cxx11-abi) + PYTORCH_LINK="libtorch" + PYTORCH_SHA="21d05ad61935fc70912c779443dba112bda9c9ec1c999345d724935828f81c55" + shift + ;; + esac +done + +if [ ! -d ${PYTORCH_INSTALL_TO}/libtorch ]; then + curl -s -L -O --remote-name-all https://download.pytorch.org/libtorch/cpu/${PYTORCH_LINK}-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip + echo "${PYTORCH_SHA} ${PYTORCH_LINK}-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip" | sha256sum -c + unzip -q "${PYTORCH_LINK}-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip" -d ${PYTORCH_INSTALL_TO} + rm -f "${PYTORCH_LINK}-shared-with-deps-${PYTORCH_VERSION}%2Bcpu.zip" +fi