-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tfjs-tflite] Loading second TFLite model hangs in _emscripten_futex_wait #6094
Comments
I'm seeing this same issue - I can only load one tflite model. The hang happens at model init, and only if COOP/COEP headers are set. Here's a minimal reproduction - you just need to serve it with COOP/COEP headers: <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@3.20.0/dist/tf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-tflite@0.0.1-alpha.9/dist/tf-tflite.min.js"></script>
<script type="module">
console.log("Attempting to load models...");
let model1 = await tflite.loadTFLiteModel("https://huggingface.co/rocca/lyra-v2-soundstream/resolve/main/tflite/soundstream_encoder.tflite");
let model2 = await tflite.loadTFLiteModel("https://huggingface.co/rocca/lyra-v2-soundstream/resolve/main/tflite/lyragan.tflite");
console.log("Loaded models.")
</script> It loads fine if you comment out one of the I used this tfjs-tflite build by @jinjingforever and paused the execution in DevTools to see the stack trace: Note: If the page isn't served with COOP/COEP headers, then both models seem to load without errors: https://jsbin.com/pahaxaromo/edit?html,output but these models use threads during inference, and so an error will be thrown when trying to use the models for prediction. |
Hi @reuben ,
I have loaded two TFLite models in the same code flow and they have loaded perfectly. |
I'm no longer working on this project, so I can't verify with the original models. |
Alright, thank you for the confirmation. It seems like this issue has been resolved with the latest version of |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you. |
Hi @shmishra99 I can still replicate this problem in tfjs v4.5.0: https://josephrocca.github.io/lyra-v2-soundstream-web/tflite-simple.html Important to note that threads must be enabled to replicate this bug. That means you must serve the file with COOP/COEP headers. In the above There is no problem with the single-threaded tfjs-lite runtime, which I'm guessing is what you used in your recent tests. @google-ml-butler Please remove stale tag. |
Commenting here as issue opener to make sure the last comment doesn't fall through the automated cracks. |
Closing as stale. Please @mention us if this needs more attention. |
@google-ml-butler not stale, steps to repro in #6094 (comment) |
@shmishra99 FYI someone provided reproduction steps with TFJS v4.5.0 |
still there, in electron second load will freeze everything.
The same behaviour with just loading the same model twice:
Version "@tensorflow/tfjs@^4.16.0" That example from the comment above would also freeze after printing first "Output shape":
|
Hi, I noticed that it depends not so much on the number of initialized models, but on the number of threads specified in the initialization. Even one model can hang if a large number of threads are specified as a parameter. For example, one of the models hangs during such initialization:
But such initialization will work stably:
P.S. |
System information
Describe the current behavior
Trying to load two
TFLite
models causes the browser to hang on the secondtflite.loadTFLiteModel
call.Describe the expected behavior
Being able to load more than a single model at a time.
Standalone code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Colab/CodePen/any notebook.
I don't have an easy way to share the model files but here's the entire script: https://gist.github.com/reuben/4d1a77251ad73629f54429705ab022a9
Copy two TFLite model files to a folder and name one of them
featurizer.tflite
and the otheroutput_graph.tflite
, then open taht page, click the model picker and select both files. The script loops forever inside_emscripten_futex_wait
on the secondtflite.loadTFLiteModel
call.Other info / logs Include any logs or source code that would be helpful to
diagnose the problem. If including tracebacks, please include the full
traceback. Large logs and files should be attached.
The text was updated successfully, but these errors were encountered: