waittim / waittim.github.io

Personal blog: https://waittim.github.io/
MIT License
0 stars 2 forks source link

Tutorial for compiling NCNN with WASM - Zekun Wang's Blog | Data Science #28

Open waittim opened 3 years ago

waittim commented 3 years ago

https://waittim.github.io/2020/11/15/build-ncnn-wasm/

Across the Great Wall, we can reach every corner in the world

jonatanhdz commented 3 years ago

Hi, first of all thank you for sharing your knwoledge, this kind of articles are like a water in the dessert when you are searching a guide about non popular topic. I'm following your tutorial to run a NCNN face detector model in browser with web assembly but I'm getting an error if I use ncnn without simd and pthread support. I copied the nccn install folder builded with Emscripten for general compatibility, then modified the file CMakeLists.txt as described in the article, modified the file yolo.cpp to disable vulkan and compiled the c++ code. When I try to run with the compiled files I get "Uncaught (in promise) RuntimeError: abort(undefined). Build with -s ASSERTIONS=1 for more info." I trace the error and seems to be where the wasm module is loaded because the onRuntimeInitialized callback is not being called in the javascript code.

waittim commented 3 years ago

@jonatanhdz Hi, first of all thank you for sharing your knwoledge, this kind of articles are like a water in the dessert when you are searching a guide about non popular topic. I'm following your tutorial to run a NCNN face detector model in browser with web assembly but I'm getting an error if I use ncnn without simd and pthread support. I copied the nccn install folder builded with Emscripten for general compatibility, then modified the file CMakeLists.txt as described in the article, modified the file yolo.cpp to disable vulkan and compiled the c++ code. When I try to run with the compiled files I get "Uncaught (in promise) RuntimeError: abort(undefined). Build with -s ASSERTIONS=1 for more info." I trace the error and seems to be where the wasm module is loaded because the onRuntimeInitialized callback is not being called in the javascript code.

Before compiling the version without simd and pthread, you need to make sure that your yolo.cpp file does not use anything related to it.

waittim commented 3 years ago

Hi, first of all thank you for sharing your knwoledge, this kind of articles are like a water in the dessert when you are searching a guide about non popular topic. I'm following your tutorial to run a NCNN face detector model in browser with web assembly but I'm getting an error if I use ncnn without simd and pthread support. I copied the nccn install folder builded with Emscripten for general compatibility, then modified the file CMakeLists.txt as described in the article, modified the file yolo.cpp to disable vulkan and compiled the c++ code. When I try to run with the compiled files I get "Uncaught (in promise) RuntimeError: abort(undefined). Build with -s ASSERTIONS=1 for more info." I trace the error and seems to be where the wasm module is loaded because the onRuntimeInitialized callback is not being called in the javascript code.

I uploaded the yolo.cpp and CMakeList.txt for no-simd&pthread version. Hope it helps.

lizozom commented 2 years ago

Thank you for making this detailed post. I think I have the opposite problem from the previous comment: I'm running on Ubuntu 20.04 64 bit laptop and I'm able to compile ncnn without simd and threads, however if I try to compile it with those options, I get errors when running the tests (and the later steps fail as well):

      Start 63: test_power
62/87 Test #62: test_pooling3d ...................***Failed    0.67 sec
failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): Compiling function #22 failed: invalid simd opcode @+10200
Aborted(CompileError: WebAssembly.instantiate(): Compiling function #22 failed: invalid simd opcode @+10200)
/Projects/ncnn/build/tests/test_pooling3d.js:1

Any clue what could cause this?

Thank you!

waittim commented 2 years ago

Hi @lizozom, I tried to retrieve something about it from my memory but I failed. It has been a while. I would recommend you reach out to the NCNN maintenance team at github.com/Tencent/ncnn and maybe they have some idea about it. Sorry I cannot help.