Tfjs: Wasm-simd-threaded backend stuck

Created on 6 Oct 2020  路  11Comments  路  Source: tensorflow/tfjs

Please make sure that this is a bug. As per our
GitHub Policy,
we only address code/doc bugs, performance issues, feature requests and
build/installation issues on GitHub. tag:bug_template

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): Not yet
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOS 10.15.6
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow.js installed from (npm or script link):
  • TensorFlow.js version (use command below):
  • Browser version: Chrome 85.0.4183.121 / Canary 88.0.4283.0
  • Tensorflow.js Converter Version:

Describe the current behavior
Hi tfjs developers,
I've been trying wasm simd threaded backend on https://tfjs-wasm-simd-demo.netlify.app/
But under my environment (Macbook pro + Google Chrome), the demo will stuck after few seconds only when simd enabled.
Since we're trying to build some feature based on wasm backend instead of webgl, is there any advice to stop the hanging problem?

Describe the expected behavior
Wasm backend + SIMD + threaded mode work properly

models wasm bug

All 11 comments

@lcycoding thanks for reporting , @annxingyuan I was able to reproduce the same behavior.

Hi @lcycoding - are you saying that Wasm + SIMD + threaded works, but Wasm + SIMD + non-threaded does not? Also, does non-SIMD work for you?

Basically I'm trying to figure out which of the permutations of SIMD / threaded support is failing.

@annxingyuan
OK, here's the combination that I've tried

Macbook Pro + Google Chrome 85
Wasm + SIMD + Threaded -> Fail, hanged after few seconds(or minutes)
Wasm + Non SIMD + Threaded -> Stable
Wasm + Non SIMD + Non Threaded -> Stable

Windows PC + Google Chrome 85
Wasm + SIMD + Threaded -> Live longer than macbook, but will hang eventually
Wasm + Non SIMD + Threaded -> Stable
Wasm + Non SIMD + Non Threaded -> Stable

Linux PC + Google Chrome 85
Wasm + SIMD + Threaded -> Live longer than macbook, but will hang eventually
Wasm + Non SIMD + Threaded -> Stable
Wasm + Non SIMD + Non Threaded -> Stable

According to the above situation, I believe there might be something wrong with SIMD...

Thanks so much @lcycoding - would you mind trying one more configuration: Wasm + SIMD + non-threaded?

Hi @annxingyuan ,
Sorry didn't bring my macbook pro home, but I tried on Macbook Air
Here's the result
Wasm + SIMD + Threaded -> Fails immediately
Wasm + SIMD + Non Threaded -> Seems stable, just tried few minutes
Wasm + Non SIMD + Threaded -> Seems stable, just tried few minutes
Wasm + Non SIMD + Non Threaded -> Seems stable, just tried few minutes

Thanks for your prompt reply!

Hi @lcycoding - thanks again for reporting this - it may take us a bit to get to the bottom of the issue. In the meantime, I'm curious how you are toggling SIMD / thread support? Through Chrome flags?

Also, you may want to try our benchmarking page to test instead, it is a more stripped down environment.

Yes, I'm toggling the switch through chrome flags.
Will try the benchmark page, thanks!

@annxingyuan
Sorry for bothering, the benchmark page works fine.
After finishing performance evaluation, we were trying to adopt wasm + SIMD + threaded on our side.
But it comes out that the loading process of tfjs-backend-wasm-threaded-simd config will make our webapp hang.
Keep receiving the following error callback

3292d53d-3d24-486e-9d64-eb899590fc44:1 ReferenceError: t is not defined
at WasmBackendModuleThreadedSimd (5cf07358-5ca8-4459-a8dc-936e498a13ac:71)
at onmessage (3292d53d-3d24-486e-9d64-eb899590fc44:1)

Any thought on this?

Hi @lcycoding - hmm, it's tough to know where that error message is coming from - but given that the benchmark page works for you, I'm hoping this is an issue with setup. One thing to be aware of is that our WASM backend fetches a binary file after it's been loaded, and by default it will assume that the binary file is located in the same directory. So if you are serving the WASM backend yourself, you'll need to make sure to also serve the binary files. There's more information on this issue here and here.

Also curious whether wasm + SIMD + non-threaded has the same configuration issue?

Hi @annxingyuan, thanks for the reply.
Non-threaded configuration works well.
Also, I've been setting the wasmPath to my own directory.
I'll check with the information you given.

I can replicate the issue as per the OP on the Netlify app running Chrome 86 on macOS 10.15.7 (19H15) - this crashes the tab completely.

I'm also experiencing a tab crash here: https://tensorflow.github.io/tfjs/e2e/benchmarks/local-benchmark/index.html

I've found that I have a similar problem on an app of my own using Blazeface 0.0.5 and TFJS 2.7.0, where I get another "o is not defined" error.

I'm also toggling threads and simd using Chrome flags.

Not sure whether it's a problem with Chrome, TFJS, the fact I'm running Blazeface which doesn't officially support 2.7.0 (so I assume it hasn't been tested with simd + threads, although "vanilla" WASM works great.)

Was this page helpful?
0 / 5 - 0 ratings