AnswerDotAI / gpu.cpp

A lightweight library for portable low-level GPU computation using WebGPU.
https://gpucpp.answer.ai
Apache License 2.0
3.68k stars 175 forks source link

web browser build example works on OSX but fails with linux x86 #38

Closed austinvhuang closed 1 month ago

austinvhuang commented 1 month ago

examples/web works on mac, but on ubuntu linux (x86 on an x1 nano), the adapter request fails (TODO(avh): check error code):

Hello gpu.cpp!
--------------

[info] Requesting adapter
[error] Error in file ../../gpu.h line 704:
Request WebGPU adapter
program exited (with status: 1), but keepRuntimeAlive() is set (counter=0) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)
austinvhuang commented 1 month ago

Resolved.

The issue is WebGPU wasn't enabled on linux chrome. Resolution required two steps:

In the medium term once webgpu chrome support is stabilized across all platforms these issues shouldn't come up at all, but for the time being I've added error message breadcrumbs for browser builds behind an #ifdef __EMSCRIPTEN__ flag when adapter request fails with these two steps in commit 24caba0221f624441eb6f3e9bc3063083eaf3237

image