Open ThorvaldAagaard opened 1 year ago
You should ask (not here it is completely out of scope for pygbag runtime) for a proper wasm port of Tensorflow to cpython-wasm or more likely pyodide.
From a quick search it is not impossible see https://blog.tensorflow.org/2020/03/introducing-webassembly-backend-for-tensorflow-js.html
Of course your game won't run of most of already deployed mobile devices because of wasm extensions used that are NOT implemented, or not available because lack of updates.
transerfing issue to porting section
That was a major setback. I am mostly interested in getting it to work on the web, Mobile devices in the distant future, I now have a plying application, but I have no idea how to port tensorflow for use in pygbag. Are there any descriptions of how to make the port, or anyone that can perform the port. I will be happy to help testing it.
I don't know much about gpu computing and tensorflow but i guess most people will wait for webgpu+wasm2 to do that kind of - very - complicated stuff.
All my models are locally trained, and it is just the usage of the models in a web-context, that is interesting, so no gpu-computing needed.
Implementation is at: https://github.com/ThorvaldAagaard/bridge-with-ben and looking thru the code, there are not much tensorflow usage besides opening the models, and calling then.
so basically you only need a small part of tensorflow like a "runtime" only ? if so cannot you call the existing wasm implementation via javascript window object from pygbag ?
Yes, a sort of runtime.
I am only accessing these classes: tf.Graph() tf.compat.v1.Session() tf.compat.v1.train.import_meta_graph() tf.nn.softmax()
I have been looking at how to use the generated models from javascript, but not found a solution (yet), as the input to calling the models are numpy arrays (and very complex). If I could get that to work the game would probably be implemented in javascript/typescript/flutter :-)
But where can I read more about how to use the javascript window object from pygbag?
sorry no doc about that but most objects are 1:1 mapping to python except promises, but the goal is not to "use" js it is more "you can pass pointers and do memcpy with js", it would only serve as a transport beetween wasm memories ( that if the above wasm implementation of runtime cannot be linked or dlopened directly : i don't have time to investigate now so idk)
My game is using Tensorflow, and it runs fine locally, but when I deploy it as a pygbag-solution I get the following error
How can I fix that?