Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysext: add llamaedge recipe #103

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,32 @@ storage:
hard: false
```

#### LlamaEdge

The llamaedge sysext can be configured by using the following snippet:

```
variant: flatcar
version: 1.0.0
storage:
files:
- path: /opt/extensions/wasmedge-0.14.1-x86-64.raw
mode: 0420
contents:
source: https://github.com/flatcar/sysext-bakery/releases/download/latest/wasmaedge-0.14.1-x86-64.raw
- path: /opt/extensions/llamaedge-0.14.16-x86-64.raw
mode: 0420
contents:
source: https://github.com/flatcar/sysext-bakery/releases/download/latest/llamaedge-0.14.16-x86-64.raw
links:
- target: /opt/extensions/llamaedge-0.14.16-x86-64.raw
path: /etc/extensions/llamaedge.raw
hard: false
- target: /opt/extensions/wasmedge-0.14.1-x86-64.raw
path: /etc/extensions/wasmedge.raw
hard: false
```

### Building sysext images

To use the build scripts in this repository, the following packages are required:
Expand Down
54 changes: 54 additions & 0 deletions create_llamaedge_sysext.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
set -euo pipefail

export ARCH="${ARCH-x86-64}"
SCRIPTFOLDER="$(dirname "$(readlink -f "$0")")"

if [ $# -lt 2 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Usage: $0 VERSION SYSEXTNAME"
echo "The script will download the llamaedge release tar ball (e.g., for 0.14.16) and create a sysext squashfs image with the name SYSEXTNAME.raw in the current folder."
echo "A temporary directory named SYSEXTNAME in the current folder will be created and deleted again."
echo "All files in the sysext image will be owned by root."
echo "To use arm64 pass 'ARCH=arm64' as environment variable (current value is '${ARCH}')."
"${SCRIPTFOLDER}"/bake.sh --help
exit 1
fi

VERSION="$1"
SYSEXTNAME="$2"

# The github release uses different arch identifiers, we map them here
# and rely on bake.sh to map them back to what systemd expects
if [ "${ARCH}" = "amd64" ] || [ "${ARCH}" = "x86-64" ]; then
ARCH="x86_64"
elif [ "${ARCH}" = "arm64" ]; then
ARCH="aarch64"
fi

# llamaedge is a wasm application, which requires WasmEdge and its WASI-NN GGML/GGUF plugin
hydai marked this conversation as resolved.
Show resolved Hide resolved
WASMEDGE_VERSION="0.14.1"

# Download WasmEdge WASI-NN GGML/GGUF plugin
rm -f "WasmEdge-plugin-wasi_nn-ggml-${WASMEDGE_VERSION}.tar.gz"
curl -o "WasmEdge-plugin-wasi_nn-ggml-${WASMEDGE_VERSION}.tar.gz" -fsSL "https://github.com/WasmEdge/WasmEdge/releases/download/${WASMEDGE_VERSION}/WasmEdge-plugin-wasi_nn-ggml-${WASMEDGE_VERSION}-ubuntu20.04_${ARCH}.tar.gz"

# Download llamaedge api server
rm -f "llama-api-server.wasm"
curl -o "llama-api-server.wasm" -fsSL "https://github.com/LlamaEdge/LlamaEdge/releases/download/${VERSION}/llama-api-server.wasm"

rm -rf "${SYSEXTNAME}"
mkdir -p "${SYSEXTNAME}"

tar --force-local -xvf "WasmEdge-plugin-wasi_nn-ggml-${WASMEDGE_VERSION}.tar.gz" -C "${SYSEXTNAME}"
mv "llama-api-server.wasm" "${SYSEXTNAME}"

rm "WasmEdge-plugin-wasi_nn-ggml-${WASMEDGE_VERSION}.tar.gz"

mkdir -p "${SYSEXTNAME}"/usr/lib/wasmedge # for plugins
mkdir -p "${SYSEXTNAME}"/usr/lib/wasmedge/wasm # for llamaedge application

mv "${SYSEXTNAME}"/libwasmedgePluginWasiNN.so "${SYSEXTNAME}"/usr/lib/wasmedge
mv "${SYSEXTNAME}"/llama-api-server.wasm "${SYSEXTNAME}"/usr/lib/wasmedge/wasm

"${SCRIPTFOLDER}"/bake.sh "${SYSEXTNAME}"
rm -rf "${SYSEXTNAME}"
2 changes: 2 additions & 0 deletions release_build_versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ ollama-0.3.9
containerd-2.0.0

wasmedge-0.14.1

llamaedge-0.14.16