facebookresearch / audiocraft

Audiocraft is a library for audio processing and generation with deep learning. It features the state-of-the-art EnCodec audio compressor / tokenizer, along with MusicGen, a simple and controllable music generation LM with textual and melodic conditioning.
MIT License
20.15k stars 2.01k forks source link

Getting error while trying to generate audio using audiogen #436

Closed adityarajsahu closed 3 months ago

adityarajsahu commented 3 months ago

When I am running the following code ` import torchaudio from audiocraft.models import AudioGen from audiocraft.data.audio import audio_write

model = AudioGen.get_pretrained('facebook/audiogen-medium') model.set_generation_params(duration=5) # generate 5 seconds. descriptions = ['dog barking', 'sirenes of an emergency vehicule', 'footsteps in a corridor'] wav = model.generate(descriptions) # generates 3 samples.

for idx, one_wav in enumerate(wav):

Will save under {idx}.wav, with loudness normalization at -14 db LUFS.

audio_write(f'{idx}', one_wav.cpu(), model.sample_rate, strategy="loudness", loudness_compressor=True)

`

locally I am getting the following error torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 14.00 MiB. GPU 0 has a total capacty of 3.81 GiB of which 7.75 MiB is free. Including non-PyTorch memory, this process has 3.79 GiB memory in use. Of the allocated memory 3.09 GiB is allocated by PyTorch, and 9.11 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

and when running on colab I am getting the following error ValueError: Could not find the operator torchvision::nms. Please make sure you have already registered the operator and (if registered from C++) loaded it via torch.ops.load_library

How to fix these issues?

wilmardarragueira commented 3 months ago

yeah, having the same error

Harushii18 commented 3 months ago

Same also having that error

KMOSNU commented 3 months ago

I had the same error on Colab(when running get_pretrained), but when I added two lines in requirement.txt , it seems working (But now I am running on local, not Colab). plz anyone add these two lines in requirement.txt and try on Colab

torchvision==0.16.0 torchtext==0.16.0

AndreaChenna commented 3 months ago

Yes, it works in colab also. Thanks a lot

(I entered 2 lines:

!pip install torchvision==0.16.0 !pip install torchtext==0.16.0

Between first and second block of code)

adityarajsahu commented 3 months ago

@KMOSNU thanks, it works