yomorun / yomo-wasmedge-tensorflow

This application demonstrates how to launch high-performance "serverless" functions from the YoMo framework to process streaming data. The functions are embedded in a WebAssembly VM, WasmEdge, for safety, security, portability, and manageability.
MIT License
63 stars 18 forks source link

Trouble in leveraging generated rust_mobilenet_food_lib_bg.so #6

Closed qiangyupei closed 3 years ago

qiangyupei commented 3 years ago

Hello, interesting project. I encounter some problems when using it. First, I uses the rustwasmc build --enable-aot command to generate the .so file by myself. However, there arises the error When executing function name: "__wbindgen_malloc" panic: toWasmEdgeValueSlideBindgen(): malloc failed. How can I solve the problem? And how to correctly generate the wasm .so file for use? Another question is that when I use the .wasm file instead of the .so file in the function LoadWasmFile, the DNN inference time (denoted by Finished post-processing in) increases from about 200 ms to 800 ms, which seems so strange. I cannot figure it out. Thank you for the answers in advance.

juntao commented 3 years ago

Hi, just to make sure: the wasm file worked but the so file failed? What did you use to compile the wasm file to so? Was it wasmedgec or wasmedgec-tensorflow?

qiangyupei commented 3 years ago

Yes, I use the rustwasmc compiler and the rustwasmc build --enable-aot command to generate the .so file and .wasm file at the same time. The .wasm file worked, while the .so file encountered the error When executing function name: "__wbindgen_malloc" panic: toWasmEdgeValueSlideBindgen(): malloc failed.

qiangyupei commented 3 years ago

My version: yomo-wasmedge-tensorflow 0.2.0, rustwasmc 0.1.29, yomo CLI 0.1.3. Did you mean using the wasmedgec or wasmedgec-tensorflow tool to compile the generated .wasm file to .so, instead of using the .so file generated by rustwasmc build --enable-aot directly?

xiaojian-hong commented 3 years ago

My version: yomo-wasmedge-tensorflow 0.2.0, rustwasmc 0.1.29, yomo CLI 0.1.3. Did you mean using the wasmedgec or wasmedgec-tensorflow tool to compile the generated .wasm file to .so, instead of using the .so file generated by rustwasmc build --enable-aot directly?

Hi @peiqiangyu , Could you please use wasmedgec (version 0.8.2) to compile the .wasm file to .so?

wasmedgec rust_mobilenet_food_lib_bg.wasm rust_mobilenet_food_lib_bg.so
qiangyupei commented 3 years ago

My version: yomo-wasmedge-tensorflow 0.2.0, rustwasmc 0.1.29, yomo CLI 0.1.3. Did you mean using the wasmedgec or wasmedgec-tensorflow tool to compile the generated .wasm file to .so, instead of using the .so file generated by rustwasmc build --enable-aot directly?

Hi @peiqiangyu , Could you please use wasmedgec (version 0.8.2) to compile the .wasm file to .so?

wasmedgec rust_mobilenet_food_lib_bg.wasm rust_mobilenet_food_lib_bg.so

Thanks a lot, and it works now. The execution time drops from 800 ms to almost 100 ms as compared to using .wasm file.

DarumaDocker commented 3 years ago

@peiqiangyu This performance difference between .wasm and .so lies in interpreter vs AOT compilation, the latter has compiled wasm into a more efficient native binary(.so), so it can properly maximize the performance of the hardware.

qiangyupei commented 3 years ago

@peiqiangyu This performance difference between .wasm and .so lies in interpreter vs AOT compilation, the latter has compiled wasm into a more efficient native binary(.so), so it can properly maximize the performance of the hardware.

Thank you for your answer. It also confuses me that the .so generated by rustwasmc build --enable-aot doesn't work, and both flags '--enable-aot' and '--enable-ext' seems useless during building.