WebGPU for ONNX Runtime on openSUSE, and a photo editor that uses it
TL;DR: ONNX Runtime 1.31.0 in science:machinelearning now has the WebGPU execution provider, so models can run on the GPU through Vulkan. In September that looked impossible to package. During Hack Week 26 I found a way to build Dawn, the WebGPU implementation it needs, offline. I also packaged greycard 0.13.1, a raw photo editor that loads the system ONNX Runtime for its AI denoising and masks. It is in review for the graphics project.
Why it was not packaged
With WebGPU on, ONNX Runtime's build fetches Dawn, and Dawn's configure step git-clones about 20 more repositories. OBS builds have no network. When I updated the package to 1.29.0 in September, the only offline route I found meant bundling hundreds of megabytes of Dawn dependencies, so WebGPU stayed off.
How it builds now
Four of those sources turned out to be enough. The package carries them, at the commits pinned in Dawn's DEPS file: SPIRV-Headers, SPIRV-Tools, Vulkan-Headers and Vulkan-Utility-Libraries. abseil comes from the system, and so do the Python modules Dawn's code generators need. A custom Dawn source path skips ONNX Runtime's own Dawn patches, so the spec applies them by hand. Dawn is built from the version ONNX Runtime 1.31.0 pins, with its Vulkan backend. The C++ library gets WebGPU on x86_64 and aarch64; the Python flavours stay CPU only.
The first version shipped Dawn as its own library, libwebgpu_dawn0. Dawn has
no soname and no stable ABI, so that name would have been made up and could
not stay unambiguous across Dawn updates. Debian packages Dawn as
libwebgpu-dawn0, with the same made-up soname, and I found no distribution
that ships ONNX Runtime with WebGPU enabled. The current package links Dawn
statically into libonnxruntime1, as upstream does by default. It declares
bundled(dawn) and three of its dependencies that get compiled in, ships
their licence texts, and recommends libvulkan1, which Dawn opens at run
time.
The request to the devel project had been created before the static version went into my branch, and it was accepted while I was submitting the update. OBS accepts a request at the revision it was created from, and its cleanup option then deleted the branched package, fix included. The fix went straight into science:machinelearning as r20, 13 minutes later. The package is not in Factory yet.
greycard
greycard is written in Rust with Slint. Upstream loads its own prebuilt ONNX
Runtime from beside the executable, and only on x86-64-v3 processors, which
that build needs. A patch makes it take the system libonnxruntime.so.1 on
any x86-64 processor. Two more changes: the check for new releases on GitHub is
off by default, because zypper handles updates, and SQLite is the system
library instead of the copy bundled in rusqlite.
A review before the submission found three problems, fixed before the request went out:
- the first loader patch still sat behind upstream's CPU check, so it did nothing on older processors;
- the License tag missed an OFL font, and SQLite was still the bundled copy;
- a Recommends line used a Fedora package name.
The request is sr#1402769.
Not tested: running a model through the WebGPU provider on a real GPU, and
greycard's AI features. What was checked: the OBS builds (ONNX Runtime on
Tumbleweed x86_64 and aarch64, greycard on x86_64), rpmlint with no errors on
ONNX Runtime, and that Dawn is inside libonnxruntime with no separate library
to install.
How this was made
AI help: an AI agent checked how other distributions package Dawn, reviewed
both packages before submission, and ran the local builds.
Code: the spec files and patches were reviewed line by line by me, like any
other patch, and checked in OBS builds.