https://github.com/second-state/wasmedge-tensorflow
https://github.com/second-state/wasmedge-tensorflow
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/second-state/wasmedge-tensorflow
- Owner: second-state
- Created: 2020-11-02T07:50:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-06-27T21:28:02.000Z (almost 3 years ago)
- Last Synced: 2025-05-07T18:57:36.053Z (about 1 year ago)
- Language: C++
- Size: 124 KB
- Stars: 12
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE.spdx
Awesome Lists containing this project
README
# WasmEdge for Tensorflow Extension (WILL BE DEPRECATED SOON)
> The WasmEdge extension will be deprecated soon and be replaced by the [WasmEdge-Tensorflow plug-in](https://wasmedge.org/docs/contribute/source/plugin/tensorflow) and the [WasmEdge-TensorflowLite plug-in](https://wasmedge.org/docs/contribute/source/plugin/tensorflowlite).
The [WasmEdge](https://github.com/WasmEdge/WasmEdge) is a high performance WebAssembly runtime optimized for server side applications. This project provides support for accessing with [Tensorflow C library](https://www.tensorflow.org/install/lang_c).
## Getting Started
### Requirements
The WasmEdge Tensorflow shared library `libwasmedge-tensorflow_c.so` and `libwasmedge-tensorflowlite_c.so` are provided for the `WasmEdge-Tensorflow` extension of the WasmEdge shared library.
The WasmEdge Tensorflow static library `libwasmedgeHostModuleWasmEdgeTensorflow.a` and `libwasmedgeHostModuleWasmEdgeTensorflowLite.a` are provided for statical linking when building executables with CMake.
When linking with `libwasmedge-tensorflow_c.so` and `libwasmedgeHostModuleWasmEdgeTensorflow.a`, the TensorFlow shared libraries `libtensorflow_cc.so` and `libtensorflow_framework.so` are required.
When linking with `libwasmedge-tensorflowlite_c.so` and `libwasmedgeHostModuleWasmEdgeTensorflowLite.a`, the TensorFlow-Lite shared library `libtensorflowlite_c.so` is required.
The official TensorFlow release only provide the TensorFlow shared library.
You can download and install the pre-built shared libraries:
```bash
wget https://github.com/second-state/WasmEdge-tensorflow-deps/releases/download/0.12.1/WasmEdge-tensorflow-deps-TF-0.12.1-manylinux2014_x86_64.tar.gz
tar -zxvf WasmEdge-tensorflow-deps-TF-0.12.1-manylinux2014_x86_64.tar.gz
rm -f WasmEdge-tensorflow-deps-TF-0.12.1-manylinux2014_x86_64.tar.gz
ln -sf libtensorflow_cc.so.2.6.0 libtensorflow_cc.so.2
ln -sf libtensorflow_cc.so.2 libtensorflow_cc.so
ln -sf libtensorflow_framework.so.2.6.0 libtensorflow_framework.so.2
ln -sf libtensorflow_framework.so.2 libtensorflow_framework.so
wget https://github.com/second-state/WasmEdge-tensorflow-deps/releases/download/0.12.1/WasmEdge-tensorflow-deps-TFLite-0.12.1-manylinux2014_x86_64.tar.gz
tar -zxvf WasmEdge-tensorflow-deps-TFLite-0.12.1-manylinux2014_x86_64.tar.gz
rm -f WasmEdge-tensorflow-deps-TFLite-0.12.1-manylinux2014_x86_64.tar.gz
```
### Prepare the environment
#### Use our docker image (Recommanded)
Our docker image is based on `ubuntu 20.04`.
```bash
docker pull wasmedge/wasmedge
```
#### Or setup the environment manually
Please notice that WasmEdge-Tensorflow requires cmake>=3.11 and libboost>=1.68.
```bash
# Tools and libraries
sudo apt install -y \
software-properties-common \
cmake \
libboost-all-dev
# WasmEdge supports both clang++ and g++ compilers
# You can choose one of them for building this project
sudo apt install -y gcc g++
sudo apt install -y clang
```
### Get WasmEdge-Tensorflow Source Code
```bash
git clone --recursive https://github.com/second-state/WasmEdge-tensorflow.git
cd WasmEdge-tensorflow
git checkout 0.12.1
```
### Build WasmEdge-Tensorflow
WasmEdge-Tensorflow depends on WasmEdge-Core, you have to prepare WasmEdge-Core before you build WasmEdge-Tensorflow.
We provides two options for setting up the WasmEdge-Core:
#### Create and Enter the Build Folder
```bash
# After pulling our WasmEdge docker image
docker run -it --rm \
-v :/root/WasmEdge-tensorflow \
wasmedge/wasmedge:latest
# In docker
cd /root/WasmEdge-tensorflow
mkdir -p build && cd build
```
#### Option 1. Use built-in CMakeLists to get WasmEdge-Core (Recommended)
```bash
# In docker
cmake -DCMAKE_BUILD_TYPE=Release .. && make
```
#### Option 2. Use specific version of WasmEdge-Core by giving WASMEDGE_CORE_PATH
```bash
# In docker
cmake -DWASMEDGE_CORE_PATH= -DCMAKE_BUILD_TYPE=Release .. && make
```
The shared library `build/lib/libwasmedge-tensorflow_c.so` is the C API to create the `wasmedge-tensorflow` import object.
The header `build/include/wasmedge-tensorflow.h` is the header of the `libwasmedge-tensorflow_c.so` shared library.
The shared library `build/lib/libwasmedge-tensorflowlite_c.so` is the C API to create the `wasmedge-tensorflowlite` import object.
The header `build/include/wasmedge-tensorflowlite.h` is the header of the `libwasmedge-tensorflowlite_c.so` shared library.
The static library `build/lib/libwasmedgeHostModuleWasmEdgeTensorflow.a` is for executables linking in CMake.
The static library `build/lib/libwasmedgeHostModuleWasmEdgeTensorflowLite.a` is for executables linking in CMake.
## WasmEdge-Tensorflow Tools
The tools is moved to the new [repository](https://github.com/second-state/WasmEdge-tensorflow-tools).