declare-lab/tango

Cannot install on Windows

SoftologyPro opened this issue · 17 comments

git clone https://github.com/declare-lab/tango/
cd tango
pip install -r requirements.txt

Ends with

Collecting accelerate==0.18.0
  Using cached accelerate-0.18.0-py3-none-any.whl (215 kB)
Collecting bitsandbytes==0.38.1
  Using cached bitsandbytes-0.38.1-py3-none-any.whl (104.3 MB)
Collecting black==22.3.0
  Using cached black-22.3.0-cp310-cp310-win_amd64.whl (1.1 MB)
Collecting compel==1.1.3
  Using cached compel-1.1.3-py3-none-any.whl (24 kB)
Collecting d4rl==1.1
  Using cached d4rl-1.1-py3-none-any.whl (26.4 MB)
Collecting data_generator==1.0.1
  Using cached Data_Generator-1.0.1-py3-none-any.whl (11 kB)
Collecting deepdiff==6.3.0
  Using cached deepdiff-6.3.0-py3-none-any.whl (69 kB)
Collecting diffusion==6.9.1
  Using cached diffusion-6.9.1-1-py3-none-any.whl (179 kB)
Collecting einops==0.6.1
  Using cached einops-0.6.1-py3-none-any.whl (42 kB)
Collecting flash_attn==1.0.3.post0
  Using cached flash_attn-1.0.3.post0.tar.gz (2.0 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\Jason\AppData\Local\Temp\pip-install-ftl4rk2a\flash-attn_362c7a8bea504f679c59d4a480161f3e\setup.py", line 6, in <module>
          from packaging.version import parse, Version
      ModuleNotFoundError: No module named 'packaging'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I have updated the requirements.txt file. Can you try a clean install again?

Collecting importlib_metadata==6.3.0
  Using cached importlib_metadata-6.3.0-py3-none-any.whl (22 kB)
ERROR: Ignored the following versions that require a different python version: 6.6.0 Requires-Python >=3.7,<3.10; 6.6.0rc2 Requires-Python >=3.7,<3.10; 6.6.1 Requires-Python >=3.7,<3.10; 6.6.2 Requires-Python >=3.7,<3.10; 6.6.3 Requires-Python >=3.7,<3.10; 6.6.4 Requires-Python >=3.7,<3.10; 6.6.5 Requires-Python >=3.7,<3.10; 6.6.6 Requires-Python >=3.7,<3.10; 6.6.7 Requires-Python >=3.7,<3.10; 6.6.8 Requires-Python >=3.7,<3.10; 6.6rc1 Requires-Python >=3.7,<3.9
ERROR: Could not find a version that satisfies the requirement intel_extension_for_pytorch==2.0.0 (from versions: none)
ERROR: No matching distribution found for intel_extension_for_pytorch==2.0.0

To be sure I have a clean setup I am making a new python venv before each test.
ie

python -m venv venv
venv\scitps\activate

I do not encounter this on Linux. Can you try installing from the latest requirements file? Otherwise, you can try installing it separately following the original instructions.

Neither v 2.0.0 or 1.113.0 install on Windows (CPU or GPU versions).
If I delete the line for intel_extension_for_pytorch then it next fails at
ERROR: No matching distribution found for jaxlib>=0.1.37
Are all these packages really needed just for tango?

OK, trying to build intel_extension_for_pytorch gives the error

File "D:\intel-extension-for-pytorch\setup.py", line 726, in make_relative_rpath
    raise "Windows support is in the plan. Intel Extension for PyTorch supports Linux now."

So, no go for Windows. Hopefully a future release of tango will consider Windows support.

I created the requirements file using pipreqs. The dependencies from audioldm and audioldm_eval were also included here. But I suspect many of the dependencies are not required. I will push a minimal requirements file in some time, and you can give it a try :)

Hey, I have updated the file with a minimal set of requirements. Let me know if it works now

OK, getting closer.
The pip install -r requirements.txt finishes without error.
But then testing with this script

import soundfile as sf
from tango import Tango
tango = Tango("declare-lab/tango")
prompt = "An audience cheering and clapping"
audio = tango.generate(prompt, steps=200)
sf.write(f"{prompt}.wav", audio, samplerate=16000)

gives this error

Traceback (most recent call last):
  File "D:\tango\tango_generate.py", line 3, in <module>
    from tango import Tango
  File "D:\tango\tango.py", line 5, in <module>
    from models import AudioDiffusion, DDPMScheduler
  File "D:\tango\models.py", line 14, in <module>
    from audioldm.audio.stft import TacotronSTFT
  File "D:\tango\audioldm\__init__.py", line 3, in <module>
    from .pipeline import *
  File "D:\tango\audioldm\pipeline.py", line 11, in <module>
    from audioldm.audio import wav_to_fbank, TacotronSTFT, read_wav_file
  File "D:\tango\audioldm\audio\__init__.py", line 2, in <module>
    from .stft import TacotronSTFT
  File "D:\tango\audioldm\audio\stft.py", line 5, in <module>
    from librosa.util import pad_center, tiny
  File "D:\tango\voc_tango\lib\site-packages\librosa\__init__.py", line 211, in <module>
    from . import decompose
  File "D:\tango\voc_tango\lib\site-packages\librosa\decompose.py", line 19, in <module>
    import sklearn.decomposition
  File "D:\tango\voc_tango\lib\site-packages\sklearn\__init__.py", line 82, in <module>
    from .base import clone
  File "D:\tango\voc_tango\lib\site-packages\sklearn\base.py", line 17, in <module>
    from .utils import _IS_32BIT
  File "D:\tango\voc_tango\lib\site-packages\sklearn\utils\__init__.py", line 19, in <module>
    from .murmurhash import murmurhash3_32
  File "sklearn\utils\murmurhash.pyx", line 1, in init sklearn.utils.murmurhash
ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 232 from C header, got 216 from PyObject

Hmm, I think the numpy version needs to be either upgraded or downgraded to 1.22.0 or 1.20.0

OK, v 1.22,0 numpy gets past that error.
Now...

  File "D:\tango\tango_generate.py", line 2, in <module>
    from tango import Tango
  File "D:\tango\tango.py", line 5, in <module>
    from models import AudioDiffusion, DDPMScheduler
  File "D:\tango\models.py", line 22, in <module>
    from diffusers.utils import randn_tensor
ImportError: cannot import name 'randn_tensor' from 'diffusers.utils' (unknown location)

Did you install diffusers from the directory provided in this repo as specified in the ReadMe?

Otherwise, you might need to add tango/diffusers/src/ to your path. randn_tensor is defined in tango/diffusers/src/diffusers/utils

OK,

cd diffusers
pip install -e .

got past that but then when running the text script it complains

    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

You can use tango = Tango("declare-lab/tango", "cpu")

One step closer, then...

  fft_window = pad_center(fft_window, filter_length)
Traceback (most recent call last):
  File "D:\tango\tango_generate.py", line 3, in <module>
    tango = Tango("declare-lab/tango", "cpu")
  File "D:\tango\tango.py", line 19, in __init__
    self.stft = TacotronSTFT(**stft_config).to(device)
  File "D:\tango\audioldm\audio\stft.py", line 150, in __init__
    self.stft_fn = STFT(filter_length, hop_length, win_length)
  File "D:\tango\audioldm\audio\stft.py", line 43, in __init__
    fft_window = torch.from_numpy(fft_window).float()
RuntimeError: Numpy is not available

pip list shows numpy v1.22.0

Can you try with numpy 1.23.0? Also you might want to use less number of steps in tango.generate() as it will take a long time to generate on CPU. The default number of steps is 100.

numpy 1.23.0 and
tango = Tango("declare-lab/tango", "cpu")
gives this

  File "D:\tango\voc_tango\lib\site-packages\torch\serialization.py", line 166, in validate_cuda_device
    raise RuntimeError('Attempting to deserialize object on a CUDA '
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

Removing the cpu directive gets it back to

  File "D:\tango\voc_tango\lib\site-packages\torch\cuda\__init__.py", line 221, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

Getting torch back to a GPU version...

pip uninstall -y torch
pip install --no-cache-dir --ignore-installed --force-reinstall --no-warn-conflicts torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1+cu116 --extra-index-url https://download.pytorch.org/whl/cu116

then gets

    from numba.np.ufunc import _internal
SystemError: initialization of _internal failed without raising an exception

getting numpy back to v1.23.0

pip uninstall -y numpy
pip install --no-cache-dir --ignore-installed --force-reinstall --no-warn-conflicts numpy==1.23.0

and IT WORKS!!! So, yes, numpy v 1.23.0 in requirements will help others.
Not sure if you want to specify the GPU versions of torch?

We used pytorch version 1.13.1+cu117. I have updated the ReadMe to include this.

Glad that the issue got resolved! Will close this now.