Skip to content

Conversation

@danbev
Copy link
Member

@danbev danbev commented Mar 24, 2025

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.

Refs: #2920

danbev added 2 commits March 24, 2025 12:14
This commit reduces the initial memory size to 256MB. 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.

Refs: ggml-org#2920
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. I've also increased the INITIAL_MEMORY to 512MB as I think we need
more after some testing.

Refs: https://emscripten.org/docs/tools_reference/settings_reference.html#initial-memory
Copy link
Member

@ggerganov ggerganov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some vague memory about an issue with the dynamic memory growth. But can't say exactly what was it and if it was WASM limitation at the time that is probably fixed now.

Anyway, lets get this in and see if it work OK.

@danbev danbev changed the title examples : reduce initial memory to 256MB examples : reduce initial memory to 512MB Mar 24, 2025
@danbev danbev merged commit 30cf30c into ggml-org:master Mar 24, 2025
47 checks passed
buxuku pushed a commit to buxuku/whisper.cpp that referenced this pull request Mar 26, 2025
* 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: ggml-org#2920
Refs: https://emscripten.org/docs/tools_reference/settings_reference.html#initial-memory
@danbev danbev deleted the examples-whisper-wasm-mem branch April 1, 2025 03:50
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

Successfully merging this pull request may close these issues.

2 participants