mlx-audio: Resource limit (499000) exceeded.
Running on a 64GB Mac Mini M4 Pro, trying to parse a file with 1109 words, getting Resource limit (499000) exceeded. at the 5th chunk.
I am running it under conda.
Parsing the same file, on my Mac Mini M4Pro 24GB, it finishes without any problems (not running under conda)
I am ignorant in all things python so i’m not sure what can be causing this.
Voice: af_heart
Speed: 1.0x
Language: a
==========
Audio generated successfully, saving to audio!
==========
Duration: 00:00:02.674
Samples/sec: 1.6
Prompt: 40 tokens, 65.0 tokens-per-sec
Audio: 1 samples, 1.6 samples-per-sec
Real-time factor: 0.23x
Processing time: 0.62s
Peak memory usage: 0.35GB
==========
Duration: 00:00:11.875
Samples/sec: 0.7
Prompt: 194 tokens, 125.5 tokens-per-sec
Audio: 1 samples, 0.7 samples-per-sec
Real-time factor: 0.13x
Processing time: 1.55s
Peak memory usage: 0.44GB
==========
Duration: 00:00:03.674
Samples/sec: 0.5
Prompt: 56 tokens, 29.8 tokens-per-sec
Audio: 1 samples, 0.5 samples-per-sec
Real-time factor: 0.51x
Processing time: 1.88s
Peak memory usage: 0.44GB
==========
Duration: 00:00:17.074
Samples/sec: 0.3
Prompt: 276 tokens, 74.7 tokens-per-sec
Audio: 1 samples, 0.3 samples-per-sec
Real-time factor: 0.22x
Processing time: 3.69s
Peak memory usage: 0.51GB
==========
Duration: 00:00:14.375
Samples/sec: 0.2
Prompt: 220 tokens, 38.9 tokens-per-sec
Audio: 1 samples, 0.2 samples-per-sec
Real-time factor: 0.39x
Processing time: 5.65s
Peak memory usage: 0.51GB
Error loading model: [metal::malloc] Resource limit (499000) exceeded.
Traceback (most recent call last):
File "/Users/andrepadez/miniconda/envs/mlx/lib/python3.11/site-packages/mlx_audio/tts/generate.py", line 76, in main
for i, result in enumerate(results):
File "/Users/andrepadez/miniconda/envs/mlx/lib/python3.11/site-packages/mlx_audio/tts/models/kokoro/kokoro.py", line 258, in generate
for segment_idx, (graphenes, phonemes, audio) in enumerate(
File "/Users/andrepadez/miniconda/envs/mlx/lib/python3.11/site-packages/mlx_audio/tts/models/kokoro/pipeline.py", line 389, in __call__
KokoroPipeline.infer(self.model, ps, pack, speed)
File "/Users/andrepadez/miniconda/envs/mlx/lib/python3.11/site-packages/mlx_audio/tts/models/kokoro/pipeline.py", line 235, in infer
return model(ps, mx.array(pack[len(ps) - 1]), speed, return_output=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrepadez/miniconda/envs/mlx/lib/python3.11/site-packages/mlx_audio/tts/models/kokoro/kokoro.py", line 155, in __call__
audio = decoder(asr, F0_pred, N_pred, ref_s[:, :128])[0] # Working fine in MLX
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrepadez/miniconda/envs/mlx/lib/python3.11/site-packages/mlx_audio/tts/models/kokoro/istftnet.py", line 1075, in __call__
x = self.generator(x, s, F0_curve) # Working in MLX
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrepadez/miniconda/envs/mlx/lib/python3.11/site-packages/mlx_audio/tts/models/kokoro/istftnet.py", line 919, in __call__
result = self.stft.inverse(spec, phase)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andrepadez/miniconda/envs/mlx/lib/python3.11/site-packages/mlx_audio/tts/models/kokoro/istftnet.py", line 623, in inverse
audio = mlx_istft(
^^^^^^^^^^
File "/Users/andrepadez/miniconda/envs/mlx/lib/python3.11/site-packages/mlx_audio/tts/models/kokoro/istftnet.py", line 498, in mlx_istft
window_sum[start:end] += w**2
~^^~
RuntimeError: [metal::malloc] Resource limit (499000) exceeded.
Execution time: 9.81s
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (15 by maintainers)
@lucasnewman / @Blaizzy I moved the mx.eval in kokoro.py so that it’s used by CLI and Web too in #35 I did some tests and it works fine, this replaces #33
Audio quality is so amazing! and this leverage sample is so great that we should add it as sample.
@ivanfioravanti Any ideas why this would differ from the command line and the web UI?
Let me check. Keep you posted.
Hmm, I can’t seem to reproduce that with the fix on my local machine, although I’m using the command-line interface and not the web UI. Does it work for you from the command line?
Actually this turned out to be pretty simple, I put up a fix here: https://github.com/Blaizzy/mlx-audio/pull/33
My pleasure!
Just install v0.0.2 and this should be solved.
Run this on your terminal:
Update, after some investigation. It sees that using
np.stacksolves both the jaggy audio and the issue you reported @andrepadez.https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/tts/models/kokoro/istftnet.py#L634
Still don’t know why. I need to investigate when I come back from the long weekend.
I managed to reproduce the issue with the main branch.
It seems like the new isft is creating large temp arrays eating up the memory and affecting the audio as well. Here: https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/tts/models/kokoro/istftnet.py#L488-L498
@lucasnewman
mx.stackmakes the audio jaggy if you use --play, it seems likenp.stackis the only thing that works when reconstructing the audio.https://github.com/Blaizzy/mlx-audio/blob/main/mlx_audio/tts/models/kokoro/istftnet.py#L634
The text1.txt is the same provided in the message above.
Sorry for the lack of details…
Thank you for your prompt reply.
text1.txt
Also please share a reproducible example.
For instance a text similar to yours
Hey @andrepadez
Thanks for sharing this issue!
Could you install from source and then run it again to see if the issue persists? We made some changes that might improve things.