You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating a custom device is supported in onnxruntime-web, but there are also several things to be careful with:
onnxruntime-web calls adapter.requestDevice(params) with specific requiredFeatures and requiredLimits in params. Creating the device using different params will not be guaranteed to work.
there are slightly different behavior between different versions for the implementation of dealing with env.webgpu.device and env.webgpu.adapter. the stable implementation is planned for onnxruntime-web 1.22.0 release.
And regarding the "powerPreference" option, it actually makes little difference:
Note: On Chrome running on dual-GPU macOS devices, if requestAdapter() is called without a powerPreference option, the high-performance discrete GPU is returned when the user's device is on AC power. Otherwise, the low-power integrated GPU is returned.
So, the difference between default and high-performance only happens on Macbook with Intel CPU when it's on battery. (seems that is the only macOS device that both has multiple GPU and can run on battery - please correct me if I was wrong)
I am also trying to figure out if setting powerPreference to "low-power" is possibly a real requirement for onnxruntime-web. If not, probably the easiest way is to always set it to "high-performance" in onnxruntime-web.
This can be linked to #960, which we can now work on thanks to onnxruntime-web exposing the device (as you point out in this PR).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Onnxruntime-web deprecated
powerPreferencein WebGPUFlag.Instead, they suggested
Reference:
https://onnxruntime.ai/docs/api/js/interfaces/Env.WebGpuFlags.html#powerPreference:~:text=Create%20your%20own%20GPUAdapter%2C%20use%20it%20to%20create%20a%20GPUDevice%20instance%20and%20set%20device%20property%20if%20you%20want%20to%20use%20a%20specific%20power%20preference.