]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
examples : reduce initial memory to 512MB (#2939)
authorDaniel Bevenius <redacted>
Mon, 24 Mar 2025 13:42:12 +0000 (14:42 +0100)
committerGitHub <redacted>
Mon, 24 Mar 2025 13:42:12 +0000 (14:42 +0100)
* examples : reduce initial memory to 512MB

This commit reduces the initial memory size to 512MB. This is done to
to avoid WebAssembly memory allocation issues on some platforms. It also
adds a flag to allow the memory to grow dynamically (up to the maximum).

The motivation for this change is that currently the initial memory is
set to 2GB which might be to large for some platforms. This will lead to
an error being thrown from the JavaScript code generated by Emscripten
when trying to allocate memory. More details can be found in the
referenced issue below.

* examples : set MAXIMUM_MEMORY instead of TOTAL_MEMORY

This commit sets MAXIMUM_MEMORY instead of TOTAL_MEMORY in the
whisper.wasm example.

The motivation for this is that TOTAL_MEMORY and INITIAL_MEMORY are
actually the same thing. Instead we want to set MAXIMUM_MEMORY to
2GB.

Refs: https://github.com/ggerganov/whisper.cpp/issues/2920
Refs: https://emscripten.org/docs/tools_reference/settings_reference.html#initial-memory

examples/whisper.wasm/CMakeLists.txt

index 75e5a8dec00bca80e3b359a570161f4e6c7535d9..10e503fdf14aba5e38a1feb42c22fd710093e5d5 100644 (file)
@@ -32,8 +32,9 @@ set_target_properties(${TARGET} PROPERTIES LINK_FLAGS " \
     --bind \
     -s USE_PTHREADS=1 \
     -s PTHREAD_POOL_SIZE_STRICT=0 \
-    -s INITIAL_MEMORY=2000MB \
-    -s TOTAL_MEMORY=2000MB \
+    -s INITIAL_MEMORY=512MB \
+    -s MAXIMUM_MEMORY=2000MB \
+    -s ALLOW_MEMORY_GROWTH=1 \
     -s FORCE_FILESYSTEM=1 \
     -s EXPORTED_RUNTIME_METHODS=\"['print', 'printErr', 'ccall', 'cwrap']\" \
     ${EXTRA_FLAGS} \