WasmEdge / WasmEdge

WasmEdge is a lightweight, high-performance, and extensible WebAssembly runtime for cloud native, edge, and decentralized applications. It powers serverless apps, embedded functions, microservices, smart contracts, and IoT devices.

Home Page:https://WasmEdge.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to solve the problem"WASI-NN plugin not installed."

V-aerus opened this issue · comments

Summary

I am currently attempting to build WasmEdge with the WASI-NN PyTorch Backend. My system is Ubuntu 20.04. I have tried installing it several times, but when running the example from https://github.com/yanghaku/WasmEdge-WASINN-examples.git, I keep getting the error message "[error] WASI-NN plugin not installed." Have you encountered similar issues before, and if so, do you have any precedents for solving them?

Appendix

I am using this :
git clone https://github.com/WasmEdge/WasmEdge.git
mkdir -p WasmEdge/build && pushd WasmEdge/build
export Torch_DIR=/home/hhs/libtorch
export WASMEDGE_PATH=/home/hhs/WasmEdge
cd ..
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_PLUGIN_WASI_NN_BACKEND="PyTorch" -DCMAKE_INSTALL_PREFIX=${WASMEDGE_PATH}

it seems no problem:

-- WASI-NN: Build PyTorch backend for WASI-NN
-- Found Torch: /home/hhs/libtorch/lib/libtorch.so  
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hhs/WasmEdge/build

then i use:
cmake --build build
[122/122] Linking CXX shared library ...ns/wasi_nn/libwasmedgePluginWasiNN.so
cd build
cmake --install .

echoed:
-- Install configuration: "Release"
-- Installing: /home/hhs/WasmEdge/lib/libwasmedge.so.0.1.0
-- Installing: /home/hhs/WasmEdge/lib/libwasmedge.so.0
-- Set runtime path of "/home/hhs/WasmEdge/lib/libwasmedge.so.0.1.0" to "$ORIGIN"
-- Installing: /home/hhs/WasmEdge/lib/libwasmedge.so
-- Installing: /home/hhs/WasmEdge/include/wasmedge/wasmedge.h
-- Installing: /home/hhs/WasmEdge/include/wasmedge/version.h
-- Installing: /home/hhs/WasmEdge/include/wasmedge/enum.inc
-- Installing: /home/hhs/WasmEdge/include/wasmedge/enum_configure.h
-- Installing: /home/hhs/WasmEdge/include/wasmedge/enum_errcode.h
-- Installing: /home/hhs/WasmEdge/include/wasmedge/enum_types.h
-- Installing: /home/hhs/WasmEdge/include/wasmedge/int128.h
-- Installing: /home/hhs/WasmEdge/lib/wasmedge/libwasmedgePluginWasiNN.so
-- Set runtime path of "/home/hhs/WasmEdge/lib/wasmedge/libwasmedgePluginWasiNN.so" to "$ORIGIN"
-- Installing: /home/hhs/WasmEdge/bin/wasmedgec
-- Set runtime path of "/home/hhs/WasmEdge/bin/wasmedgec" to "$ORIGIN/../lib"
-- Installing: /home/hhs/WasmEdge/bin/wasmedge
-- Set runtime path of "/home/hhs/WasmEdge/bin/wasmedge" to "$ORIGIN/../lib"

then i used:

export WASMEDGE_PLUGIN_PATH=/home/hhs/WasmEdge/lib/wasmedge
ldd ${WASMEDGE_PATH}/lib/wasmedge/libwasmedgePluginWasiNN.so

echoed:
linux-vdso.so.1 (0x00007ffdabfe8000)
libtorch_cpu.so => /home/hhs/libtorch/lib/libtorch_cpu.so (0x00007f78287d2000)
libtorch.so => /home/hhs/libtorch/lib/libtorch.so (0x00007f78285d0000)
libwasmedge.so.0 => /home/hhs/.wasmedge/lib/libwasmedge.so.0 (0x00007f7823591000)
libc10.so => /home/hhs/libtorch/lib/libc10.so (0x00007f7823305000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f7823108000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f78230eb000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f78230c8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7822ed6000)
/lib64/ld-linux-x86-64.so.2 (0x00007f783a34e000)
libgomp-75eea7e8.so.1 => /home/hhs/libtorch/lib/libgomp-75eea7e8.so.1 (0x00007f7822cb1000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f7822ca7000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7822ca1000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7822b52000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f7822b34000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f7822b04000)

seems like no problem,then i use:
clone the repo
git clone https://github.com/yanghaku/WasmEdge-WASINN-examples.git
cd WasmEdge-WASINN-examples
git checkout wasi-nn-0.4.0-pytorch-gpu

build the example

cd pytorch-mobilenet-image/rust

cargo build --release --target=wasm32-wasi

run the example in this folder

wasmedge --dir .:.. ./target/wasm32-wasi/release/wasmedge-wasinn-example-mobilenet-image.wasm ./mobilenet.pt ./input.jpg

but finally:
(base) hhs@WP3:~/WasmEdge-WASINN-examples/pytorch-mobilenet-image/rust$ wasmedge --dir .:.. ./target/wasm32-wasi/release/wasmedge-wasinn-example-mobilenet-image.wasm ./mobilenet.pt ./input.jpg
[2024-03-14 17:24:26.915] [error] WASI-NN plugin not installed. Please install the plugin and restart WasmEdge.
thread 'main' panicked at src/main.rs:18:6:
called Result::unwrap() on an Err value: BackendError(InvalidArgument)
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
[2024-03-14 17:24:26.916] [error] execution failed: unreachable, Code: 0x89
[2024-03-14 17:24:26.916] [error] In instruction: unreachable (0x00) , Bytecode offset: 0x000a5eb4
[2024-03-14 17:24:26.916] [error] When executing function name: "_start"

How can I solve this problem? Thank you for your help.

Try WASMEDGE_PLUGIN_PATH=${WASMEDGE_PATH}/lib/wasmedge wasmedge ....

Try WASMEDGE_PLUGIN_PATH=${WASMEDGE_PATH}/lib/wasmedge wasmedge ....

@hydai Thank you very much for your reply, but I still failed during testing.

WASMEDGE_PLUGIN_PATH=${WASMEDGE_PATH}/lib/wasmedge
echo $WASMEDGE_PLUGIN_PATH
/home/hhs/WasmEdge/lib/wasmedge
ls /home/hhs/WasmEdge/lib/wasmedge
libwasmedgePluginWasiNN.so
wasmedge --dir .:.. ./target/wasm32-wasi/release/wasmedge-wasinn-example-mobilenet-image.wasm ./mobilenet.pt ./input.jpg
[error] WASI-NN plugin not installed. Please install the plugin and restart WasmEdge.
thread 'main' panicked at src/main.rs:18:6:
called `Result::unwrap()` on an `Err` value: BackendError(InvalidArgument)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
 [error] execution failed: unreachable, Code: 0x89
[error]     In instruction: unreachable (0x00) , Bytecode offset: 0x000a5eb4
[error]     When executing function name: "_start"

Please, how do I need to deal with the above problem.if u need more information ,just tell me.Thanks!

Please check if you set up the correct things inside the environment. I am not going to debug the environment issue for you since the CI passed: https://github.com/second-state/WasmEdge-WASINN-examples/actions/runs/8273245024/job/22636641764

Doesn't this command, WASMEDGE_PLUGIN_PATH=${WASMEDGE_PATH}/lib/wasmedge wasmedge --dir .:.. ./target/wasm32-wasi/release/wasmedge-wasinn-example-mobilenet-image.wasm ./mobilenet.pt ./input.jpg, work for you?

Just tested on a clean ubuntu 20.04 docker image. You can see the result is working.

CleanShot 2024-03-14 at 19 32 18

Please check if you set up the correct things inside the environment. I am not going to debug the environment issue for you since the CI passed: https://github.com/second-state/WasmEdge-WASINN-examples/actions/runs/8273245024/job/22636641764

seems like i passed.

Doesn't this command, WASMEDGE_PLUGIN_PATH=${WASMEDGE_PATH}/lib/wasmedge wasmedge --dir .:.. ./target/wasm32-wasi/release/wasmedge-wasinn-example-mobilenet-image.wasm ./mobilenet.pt ./input.jpg, work for you?

this seems worked , as you said "tested on a clean ubuntu 20.04 docker image",i found it really worked. So I went back to look for my own problem, and ran a find command for wasmedge in my personal environment, discovering a hidden path directive that redirected my wasmedge command to another version of wasmedge that didn't have the framework installed. That's why I encountered the issue. I'm sorry for wasting your time and I appreciate your patient help. I have resolved the issue and successfully executed the example in my own environment.

Thank you very much for your help,ur assistance is greatly appreciated to me ,as a newcomer to WasmEdge.

No worries. Welcome to the WasmEdge community :-).