https://github.com/rishit-dagli/wasm-faas-tensorflow
https://github.com/rishit-dagli/wasm-faas-tensorflow
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rishit-dagli/wasm-faas-tensorflow
- Owner: Rishit-dagli
- License: apache-2.0
- Created: 2022-06-30T09:23:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-07T11:59:35.000Z (about 3 years ago)
- Last Synced: 2025-05-09T01:08:27.686Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 26.3 MB
- Stars: 6
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WebAssembly based AI as a Service with Kubernetes
## Demo 1: Run locally with WasmEdge
### Prerequisite:
- Install Rust with `rustup`
- Have GCC installed
- Git and cURL### Steps:
1. Install the `wasm32-wasi` target
```sh
rustup target add wasm32-wasi
```2. Install `wasmedge`
```sh
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash
source $HOME/.wasmedge/env
```3. Build the QuickJS interpreter with the WasmEdge Tensorflow extension
```sh
cd wasmedge-quickjs
cargo build --target wasm32-wasi --release --features=tensorflow
cd ..
```4. Run JS Examples locally
```sh
cd js_food
wasmedge-tensorflow-lite --dir .:. wasmedge_quickjs.wasm main.js
cd ..
```5. Run Rust examples locally
```sh
cd rust_mobilenet
cargo build --target wasm32-wasi --release
```We can AOT compile our Rust code to machine native code, and then use WasmEdge sandbox to run the native code.
```sh
wasmedgec-tensorflow target/wasm32-wasi/release/classify.wasm classify.so
wasmedge-tensorflow-lite classify.so < grace_hopper.jpg
```## Demo 2: Deploy as a FAAS
### Prerequisite:
- Install Rust with `rustup`
- Have GCC installed
- Git and cURL
- Vercel CLI### Steps:
1. Install the `wasm32-wasi` target
```sh
rustup target add wasm32-wasi
```2. Build the Rust program to WebAssembly bytecode
```sh
cd faas
cd api/functions/image-classification/
cargo build --release --target wasm32-wasi
```3. Prepare the build artifacts for deployment
```sh
cp target/wasm32-wasi/release/classify.wasm ../../
```4. Deploy the function
```sh
cd ../../../
vercel deploy
```## Demo 3
Build container
```sh
sudo buildah build --annotation "module.wasm.image/variant=compat" -t classify .
```