Skip to content

[Web] Static WASM library: Actually selecting WebGpuExecutionProvider #25952

@Andonvr

Description

@Andonvr

Describe the issue

I successfully built the ONNXRuntime as a static library for WebAssembly (with pretty much this approach).

I log all available execution providers like so:

printf("ONNX Runtime version: %s\n", OrtGetApiBase()->GetVersionString());
auto providers = Ort::GetAvailableProviders();
printf("Available execution providers:\n");
for (const auto& provider : providers) {
    printf("  %s\n", provider.c_str());
}

And it correctly prints

ONNX Runtime version: 1.23.0
Available execution providers:
WebGpuExecutionProvider
CPUExecutionProvider

However, when running, it seems to be using the CPUExecutionProvider? I'm not actually sure, just speed-wise this seems to be the case.
So my questions are:

  • How can I actually check which EP is used (not just which ones are available)
  • How can I force it to use the WebGpuExecutionProvider, and raise an exception otherwise?

To reproduce

Urgency

Somewhat, my bachelors thesis would highly benefit from it lol

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

ef60e38

Execution Provider

'webgpu' (WebGPU)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ep:WebGPUort-web webgpu providerplatform:webissues related to ONNX Runtime web; typically submitted using template

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions