suno-ai / bark

🔊 Text-Prompted Generative Audio Model
MIT License
36.13k stars 4.25k forks source link

My graphics card has 6GB of VRAM.,but CUDA out of memory. #310

Open ilikepython3 opened 1 year ago

ilikepython3 commented 1 year ago

from bark import SAMPLE_RATE, generate_audio, preload_models from scipy.io.wavfile import write as write_wav import os

os.environ["SUNO_OFFLOAD_CPU"] = 'True' os.environ["SUNO_USE_SMALL_MODELS"] = 'True'

preload_models()

text_prompt = """ skip """ audio_array = generate_audio(text_prompt)

write_wav("w.wav", SAMPLE_RATE, audio_array)


Traceback (most recent call last): File "D:\file\lanqiao\ba.py", line 11, in preload_models() File "D:\anaconda\envs\bark\lib\site-packages\bark\generation.py", line 318, in preloadmodels = load_model( File "D:\anaconda\envs\bark\lib\site-packages\bark\generation.py", line 275, in load_model model = _load_model_f(ckpt_path, device) File "D:\anaconda\envs\bark\lib\site-packages\bark\generation.py", line 240, in _load_model model.to(device) File "D:\anaconda\envs\bark\lib\site-packages\torch\nn\modules\module.py", line 1145, in to return self._apply(convert) File "D:\anaconda\envs\bark\lib\site-packages\torch\nn\modules\module.py", line 797, in _apply module._apply(fn) File "D:\anaconda\envs\bark\lib\site-packages\torch\nn\modules\module.py", line 797, in _apply module._apply(fn) File "D:\anaconda\envs\bark\lib\site-packages\torch\nn\modules\module.py", line 820, in _apply param_applied = fn(param) File "D:\anaconda\envs\bark\lib\site-packages\torch\nn\modules\module.py", line 1143, in convert return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) torch.cuda.OutOfMemoryError: CUDA out of memory.

How can I repair it?

fnrcum commented 1 year ago

Try my answer here https://github.com/suno-ai/bark/issues/315#issuecomment-1568127751

asterocean commented 8 months ago

I figured out a solution, load modules on demand rather than load them all at the same time, try this pull request: https://github.com/suno-ai/bark/pull/531