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.5k stars 2.06k forks source link

Audiocraft on windows, without cuda #231

Open DramaBooks opened 1 year ago

DramaBooks commented 1 year ago

Hello, I installed audiocraft on windows, using pip: pip install audiocraft Everything seems to have been successful. When I try to import audiocraft though, XFormers returns an issue warning me that cuda technology is not installed on my system. I have an intel nuc 10, my graphics card does not support cuda. Can I use the same audiocraft somehow? Can you recommend a suitable graphics card?

oxidizer05 commented 1 year ago

Delete xformers word in this file requirements.txt save file and run pip install -r requirements.txt again

jin-eld commented 5 months ago

Delete xformers word in this file requirements.txt save file and run pip install -r requirements.txt again

The issue is, that if xformers is not installed at all, there will be an error, because there is an unconditional import:

>>> from audiocraft.models import MusicGen
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/venvs/audiocraft/lib64/python3.12/site-packages/audiocraft/__init__.py", line 24, in <module>
    from . import data, modules, models
  File "/venvs/audiocraft/lib64/python3.12/site-packages/audiocraft/data/__init__.py", line 10, in <module>
    from . import audio, audio_dataset, info_audio_dataset, music_dataset, sound_dataset
  File "/venvs/audiocraft/lib64/python3.12/site-packages/audiocraft/data/info_audio_dataset.py", line 19, in <module>
    from ..modules.conditioners import SegmentWithAttributes, ConditioningAttributes
  File "/venvs/audiocraft/lib64/python3.12/site-packages/audiocraft/modules/__init__.py", line 22, in <module>
    from .transformer import StreamingTransformer
  File "/venvs/audiocraft/lib64/python3.12/site-packages/audiocraft/modules/transformer.py", line 23, in <module>
    from xformers import ops
ModuleNotFoundError: No module named 'xformers'

if I understand the docs correctly, xformers should be optional, so is there perhaps a missing check or does it still need the module to be installed, but won't use it if a different backend is selected?

jin-eld commented 5 months ago

Workaround for ROCm users:

so, apparently xformers need to be installed even if they are not being used due to the hard import from the trace above. I had to pip install triton and then pip install --no-deps xformers, the latter makes sure it does not start to pull in CUDA dependencies and the CUDA enabled PyTorch version. After that audiocraft will work, utilizing the AMD GPU

xalteropsx commented 2 months ago

@jin-eld triton is not avaible for window