question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

librosa MemoryError

See original GitHub issue

I keep getting a MemoryError from librosa

$ python train.py --checkpoint_every=1 --data_dir=data
Using default logdir: ./logdir/train/2016-11-05T21-43-34
Trying to restore saved checkpoints from ./logdir/train/2016-11-05T21-43-34 ... No checkpoint found.
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/neural-network/tensorflow-wavenet/wavenet/audio_reader.py", line 91, in thread_main
    for audio, filename in iterator:
  File "/home/neural-network/tensorflow-wavenet/wavenet/audio_reader.py", line 24, in load_generic_audio
    audio, _ = librosa.load(filename, sr=sample_rate, mono=True)
  File "/usr/local/lib/python2.7/dist-packages/librosa/core/audio.py", line 149, in load
    y = np.concatenate(y)
MemoryError

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jyegerlehnercommented, Nov 6, 2016

Looks like you need to either reduce memory consumption, or run on a machine with more memory (either host memory, GPU memory or both).

You can set sample_size (which defaults to 100000). If you set sample_size to, say 64000, then instead of having a [1,100000,512] tensor you’d get a [1,64000,512].

0reactions
bmcfeecommented, Nov 14, 2016

[threadjacking thanks to @Cortexelus]

If your input data is in a format supported by libsndfile (eg, flac/wav/ogg but not mp3), I’d recommend using soundfile instead of librosa.load (which sits on top of audioread).

librosa’s loader is really intended for short signals, and is not at all optimized for memory usage. I’ve used soundfile on long signals (~3hr duration) without a hitch though, and since it provides numpy array views of the data, it should play nicely with everything else.

(In case you’re wondering, the main reason we don’t switch librosa over to soundfile instead of audioread is mp3 support.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Librosa Memory Error
I'm using librosa's beat_track function to detect the times of beats in a wav file for a game in Pygame. However, when I...
Read more >
Python raises Memory Error despite of 16gb Swap
I'm getting MemoryError while running some large matrix operations (chroma, cqt, mfcc extraction) with numpy (1.81), scipy (0.17.0), librosa ...
Read more >
GPU memory error when trying to fine tune the whisper ...
I'm trying to fine tune the whisper model with a custom data set but I'm getting a memory error. numpy.core._exceptions.
Read more >
Troubleshooting — librosa 0.10.0.dev0 documentation
If you have questions about how to use librosa, please consult the discussion forum. For bug reports and other, more technical issues, consult...
Read more >
python 3 - librosa on a raspberry pi
I have a problem with librosa installation on raspberry pi. I followed the instructions from the comment @Austin from: Unable to pip install ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found