Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stable diffusion not work in WASM #47

Open
Joinhack opened this issue Sep 5, 2023 · 5 comments
Open

stable diffusion not work in WASM #47

Joinhack opened this issue Sep 5, 2023 · 5 comments

Comments

@Joinhack
Copy link

Joinhack commented Sep 5, 2023

Hello, I compile this project to wasm, but when I run it crash.
image

@dmikey
Copy link
Contributor

dmikey commented Sep 5, 2023

@ggerganov any chance you could give us some pointers? :) Much obliged.

@ggerganov
Copy link
Contributor

Hard to tell - could be some problem with the WASM code. It's not very well tested.

Try this patch and see what happens:

diff --git a/src/ggml.c b/src/ggml.c
index d2a9dab..8a11f7c 100644
--- a/src/ggml.c
+++ b/src/ggml.c
@@ -12260,9 +12260,7 @@ static void ggml_compute_forward_soft_max_f32(
             }
         }
 
-        assert(sum > 0.0);
-
-        sum = 1.0/sum;
+        sum = sum > 0.0 ? 1.0/sum : 1.0;
         ggml_vec_scale_f32(nc, dp, sum);
 
 #ifndef NDEBUG

@Joinhack
Copy link
Author

Joinhack commented Sep 5, 2023

yes, it work, but other error occur.

image

@rahuldshetty
Copy link

@Joinhack , if you're using Emscripten then try adding these flags and values during compilation:
-s INITIAL_MEMORY=1000MB -s MAXIMUM_MEMORY=4GB -s STACK_SIZE=11524288 -s ALLOW_MEMORY_GROWTH

This should get around the memory limitations. Example Script: https://github.com/rahuldshetty/ggml.js/blob/master/build-ggml.sh

@Joinhack
Copy link
Author

thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants