-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Web] 'Worker': ArrayBuffer at index 0 is not detachable and could not be transferred when running inference session #19488
Comments
This error means that one ArrayBuffer is used in a detached state. I may need to take a look at your code to figure out the detail. |
Thanks for the fast response! I've added you to the demo repository. Just pop the model into the |
The root cause if figured out. When using proxy, input tensors' underlying buffer is transferred from main thread into worker thread to avoid memcpy. This will invalidate any object in main thread who uses that buffer. This is why this error come out because the underlying array buffer in let noisePredText = await predict_noise(latents, timestep, positive); // this works good
let noisePredUnet = await predict_noise(latents, timestep, negative); // this cannot work , because 'latents' is based on invalid buffer I can make a fix to transfer the array buffer back to main thread after using it. |
Thanks for your response. Oh I understand, yes please make the fix if possible. I would appreciate it so much. |
@nezaBacar could you help to verify if the PR fixes the issue by consuming package built here: https://dev.azure.com/onnxruntime/onnxruntime/_build/results?buildId=1306843&view=artifacts&pathAsName=false&type=publishedArtifacts |
### Description When using proxy worker, input buffers should be transferred back to the caller thread after `run()` call is done. Fixes microsoft#19488
### Description When using proxy worker, input buffers should be transferred back to the caller thread after `run()` call is done. Fixes #19488
### Description When using proxy worker, input buffers should be transferred back to the caller thread after `run()` call is done. Fixes #19488
### Description When using proxy worker, input buffers should be transferred back to the caller thread after `run()` call is done. Fixes microsoft#19488
Describe the issue
I load two models cca. 800MB into the browser. When I attempt to run inference using a 650MB model with the ort.env.wasm.proxy flag set to true, the application crashes with an error message:
"TypeError: Failed to execute 'postMessage' on 'Worker': ArrayBuffer at index 0 is not detachable and could not be transferred."
Do you have any suggestions for preventing this error? Alternatively, if I don't set the flag to true, the inference process runs smoothly, but it causes the UI to freeze. Are there any alternative methods to prevent the UI from freezing?To reproduce
Urgency
It's somewhat urgent
ONNX Runtime Installation
Built from Source
ONNX Runtime Version or Commit ID
1.16
Execution Provider
'wasm'/'cpu' (WebAssembly CPU)
The text was updated successfully, but these errors were encountered: