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

Change allocation strategy of the distance matrix to avoid overcommit #2

Open
r4victor opened this issue Feb 12, 2021 · 8 comments
Open

Comments

@r4victor
Copy link
Owner

The DTWBD() function that performs sequence alignment allocates the whole distance matrix at once. This allocation may request a lot of memory. On Linux and Mac OS this is not a problem because they overcommit:

Overcommit refers to the practice of giving out virtual memory with no guarantee that physical storage for it exists).

And in practice, when the matrix is large, only elements in window are actually used. Windows simply won't allocate memory and return NULL. This caused some bugs before (Issue 1).

The solution is to change the code so that only elements in window are allocated. Like this, for example.

@ravigupta-art
Copy link

I tried this on linux as well, I still get the same issue.

@bhattarai333
Copy link

@ravigupta-art did you try turning on overcommit first? Run:

echo 1 | sudo tee /proc/sys/vm/overcommit_memory

In your terminal first.

@versae
Copy link
Contributor

versae commented Jan 14, 2023

I had the same issue in Linux and running the code suggested by @bhattarai333 made it work for me.

$ echo 1 | sudo tee /proc/sys/vm/overcommit_memory

@WoxWik
Copy link

WoxWik commented Feb 1, 2023

This fixes it for me initially, but then I get a "Killed". Error message.. How much ram is needed for a sync? Is 8gb not enough?

@r4victor
Copy link
Owner Author

@WoxWik, the RAM needed depends on the length of audio files. For example, when syncing a book with chapters up to an hour long (https://librivox.org/the-picture-of-dorian-gray-by-oscar-wilde/), the used memory peaks at about 1GB (tested on M1 MacBook). The used memory grows linearly with the audio length and the allocated memory grows quadratically. 8GB should be enough unless you sync much longer audio files.

@alexthesilva
Copy link

alexthesilva commented Dec 24, 2023

is there any workaround to this issue? i have an 8gb ram laptop and i really needed to sync a 6hour audiobook with this setup. do you happen to know of any software i could use to merge these epub files perhaps, or do you know of any way that perhaps the task could be split into various subtasks within the audiofile ram limits?

@bhattarai333
Copy link

is there any workaround to this issue? i have an 8gb ram laptop and i really needed to sync a 6hour audiobook with this setup. do you happen to know of any software i could use to merge these epub files perhaps, or do you know of any way that perhaps the task could be split into various subtasks within the audiofile ram limits?

You could maybe try splitting the audiofile (and text) into chunks and syncing them separately, then finally stitching them back together

@bhattarai333
Copy link

Finally got around to containerizing my application and can confirm setting overcommit to 1 and running works just fine in a VM as well as a Docker container on Windows

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

6 participants