microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.16k stars 2.86k forks source link

[Web] Yolov8 object detection on webGPU #22176

Open reinhrst opened 7 hours ago

reinhrst commented 7 hours ago

Describe the issue

I would like to get clarification if YoloV8 object detection is expected to run on webGPU. When I try it I get:

[WebGPU]: Error: softmax only supports last axis for now.

In Netron visualisation I can see a Softmax on axis 1 (which I guess accounts for the error). I understand from https://github.com/microsoft/onnxruntime/issues/20710#issuecomment-2350925366 that Softmax on WebGPU EP on arbitrary axis is somewhere planning (which would be great :)).

However looking at #19779, it suggests that Yolov8 nano should just work on WebGPU (unfortunately the link to download the model is broken, so I cannot check how that model looks).

To reproduce

Get a yolov8 nano model in onnx format (install ultralytics, then run yolo export model=yolov8n format=onnx).

Use this model in an onnx WebGPU EP, and it gives above error.

Using WASM the model works just fine.

Urgency

Rewriting my browser-based inferrer from tensorflowjs to onnx, and would love to finish, but no strict deadlines.

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.19.2.tgz

Execution Provider

'webgpu' (WebGPU)

reinhrst commented 7 hours ago

Some more info that I just found out; when I export with opset=12 it does work on WebGPU. Does that sound plausible to you? If so, do you have any suggestions what opset I should use?