Skip to content
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

Uncaught (in promise) Error: no available backend found. ERR: [wasm] TypeError: Cannot read properties of undefined (reading 'buffer'), [cpu] Error: previous call to 'initializeWebAssembly()' failed., [xnnpack] Error: previous call to 'initializeWebAssembly()' failed.[Web] #20463

Closed
dongxingwangna opened this issue Apr 25, 2024 · 2 comments
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template

Comments

@dongxingwangna
Copy link

Describe the issue

import { Models } from '../type';
import Editor from '../Editor';
import { env, InferenceSession } from 'onnxruntime-web';
import SAM from '@/model/modelFiles/sam_quantized.onnx?url';
import ortWasm from '@/model/modelWasm/ort-wasm.wasm?url';
import ortWasmSimd from '@/model/modelWasm/ort-wasm-simd.wasm?url';
import ortWasmThreaded from '@/model/modelWasm/ort-wasm-threaded.wasm?url';
import ortWasmSimdThreaded from '@/model/modelWasm/ort-wasm-simd-threaded.wasm?url';

env.debug = true;
// log level
env.logLevel = 'info';
// wasm
env.wasm.numThreads = 2;
env.wasm.simd = true;
env.wasm.wasmPaths = {
'ort-wasm.wasm': ortWasm,
'ort-wasm-simd.wasm': ortWasmSimd,
'ort-wasm-threaded.wasm': ortWasmThreaded,
'ort-wasm-simd-threaded.wasm': ortWasmSimdThreaded,
};

export default class ModelManager {
editor: Editor;
modelMap: Map<Models, InferenceSession> = new Map();
modelPath: Record<Models, string> = {
[Models.SAM]: SAM,
};

constructor(editor: Editor) {
    this.editor = editor;
}

async getModel(name: Models) {
    let model = this.modelMap.get(name);
    if (!model) {
        this.editor.showLoading(true);
        console.log('ModelManager.ts:44 ==> this.modelPath[name]-->', this.modelPath[name]);
        model = await InferenceSession.create(this.modelPath[name]);
        this.modelMap.set(name, model);
        this.editor.showLoading(false);
    }
    return model;
}

async runModel(name: Models) {
    let model = await this.getModel(name);
    console.log('ModelManager.ts:49 ==> model-->', model);
}

}
When I run the run model here, the program gets an error and the version I'm using is 1.17.3.

To reproduce

vite + vue3+onnxruntime-web1.17.3

Urgency

No response

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

1.17.3

Execution Provider

'wasm'/'cpu' (WebAssembly CPU)

@dongxingwangna dongxingwangna added the platform:web issues related to ONNX Runtime web; typically submitted using template label Apr 25, 2024
@fs-eire
Copy link
Contributor

fs-eire commented Apr 28, 2024

The error message TypeError: Cannot read properties of undefined (reading 'buffer') is probably because of the web assembly artifact file is not served correctly in the server. could you check that browser downloads the corresponding .wasm files successfully?

@gcrois
Copy link

gcrois commented May 7, 2024

Just did some debugging here -- in my environment, it looks like onnxruntime-web sends a request for /ort-wasm-simd.wasm which isn't included by the bundler. If I put the required files in /public, it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template
Projects
None yet
Development

No branches or pull requests

3 participants