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.71k stars 2.11k forks source link

CUDA out of memory error trying to run Audiogen locally #296

Open bibyts opened 1 year ago

bibyts commented 1 year ago

Tried to run Audiogen om Windows using Anaconda prompt locally and got the error below. I have a GeForce RTX 3090 with 24GB of GDDR6X memory so not sure why I'm getting CUDA out of memory error. Any idea how to resolve?

Audiogen: File "C:\Users\xxx\anaconda3\envs\audiocraft\lib\site-packages\torch\nn\modules\linear.py", line 96, in init self.weight = Parameter(torch.empty((out_features, in_features), **factory_kwargs)) torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 24.00 GiB total capacity; 2.12 GiB already allocated; 19.76 GiB free; 2.22 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Harushii18 commented 1 year ago

@bibyts What is the code you are running?

chitralekha18 commented 8 months ago

I face the same problem. This is the code snippet I run.

model = AudioGen.get_pretrained('facebook/audiogen-medium')
model.set_generation_params(
    use_sampling=True,
    top_k=250,
    duration=5
)
output = model.generate(
        descriptions=text,
        progress=True
    )

Any solutions?