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.18k stars 2.01k forks source link

ModuleNotFoundError: No module named 'torch' when attempting to install xformers #362

Open bryan-vh opened 7 months ago

bryan-vh commented 7 months ago

I'm running the following command after installing torch like the README says and I keep getting the following error:

pip install -U audiocraft

Collecting audiocraft
  Using cached audiocraft-1.1.0.tar.gz (610 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting av (from audiocraft)
  Using cached av-11.0.0-cp311-cp311-macosx_11_0_arm64.whl.metadata (4.5 kB)
Collecting einops (from audiocraft)
  Using cached einops-0.7.0-py3-none-any.whl.metadata (13 kB)
Collecting flashy>=0.0.1 (from audiocraft)
  Using cached flashy-0.0.2.tar.gz (72 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting hydra-core>=1.1 (from audiocraft)
  Using cached hydra_core-1.3.2-py3-none-any.whl (154 kB)
Collecting hydra-colorlog (from audiocraft)
  Using cached hydra_colorlog-1.2.0-py3-none-any.whl (3.6 kB)
Collecting julius (from audiocraft)
  Using cached julius-0.2.7.tar.gz (59 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting num2words (from audiocraft)
  Using cached num2words-0.5.13-py3-none-any.whl.metadata (12 kB)
Collecting numpy (from audiocraft)
  Using cached numpy-1.26.2-cp311-cp311-macosx_11_0_arm64.whl.metadata (115 kB)
Collecting sentencepiece (from audiocraft)
  Using cached sentencepiece-0.1.99-cp311-cp311-macosx_11_0_arm64.whl (1.2 MB)
Collecting spacy==3.5.2 (from audiocraft)
  Using cached spacy-3.5.2-cp311-cp311-macosx_11_0_arm64.whl (6.5 MB)
Requirement already satisfied: torch>=2.0.0 in ./.env/lib/python3.11/site-packages (from audiocraft) (2.1.1)
Collecting torchaudio>=2.0.0 (from audiocraft)
  Using cached torchaudio-2.1.1-cp311-cp311-macosx_11_0_arm64.whl.metadata (6.4 kB)
Collecting huggingface-hub (from audiocraft)
  Using cached huggingface_hub-0.19.4-py3-none-any.whl.metadata (14 kB)
Collecting tqdm (from audiocraft)
  Using cached tqdm-4.66.1-py3-none-any.whl.metadata (57 kB)
Collecting transformers>=4.31.0 (from audiocraft)
  Using cached transformers-4.35.2-py3-none-any.whl.metadata (123 kB)
Collecting xformers (from audiocraft)
  Using cached xformers-0.0.22.post7.tar.gz (3.8 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "/Users/bryanvanhorn/development/timbre/timbre-ml/timbre-ml-py/.env/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/bryanvanhorn/development/timbre/timbre-ml/timbre-ml-py/.env/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/bryanvanhorn/development/timbre/timbre-ml/timbre-ml-py/.env/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/gl/_80vrhsj0qx_rxssdbr9x4d00000gn/T/pip-build-env-yp5nvx76/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/gl/_80vrhsj0qx_rxssdbr9x4d00000gn/T/pip-build-env-yp5nvx76/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/gl/_80vrhsj0qx_rxssdbr9x4d00000gn/T/pip-build-env-yp5nvx76/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 480, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "/private/var/folders/gl/_80vrhsj0qx_rxssdbr9x4d00000gn/T/pip-build-env-yp5nvx76/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 23, in <module>
      ModuleNotFoundError: No module named 'torch'
      [end of output]

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

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

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

I'm currently on a 14" M1 Pro MacBook Pro and I saw that xformers seemed to have announced support for Macs back in September. I'm currently using Python 3.11.6 and my virtual env shows torch 2.1.1 is installed properly. I've attempted deleting the virtual env and restarting from scratch as well as using other Python versions with no luck. Any help would be greatly appreciated!

heylongman commented 7 months ago

same problem

SarthakNikhal commented 6 months ago

Can I work on this issue?

josmithiii commented 6 months ago

I too am on an M1 MacBook Pro, and installs ok for me in the environment created like this: conda create -n env_pytorch python=3.11

orikey0 commented 6 months ago

same problem

suprateembanerjee commented 4 months ago

same problem

zeke-john commented 4 months ago

same problem, on m1 mac, any update @bryan-vh @josmithiii ?

josmithiii commented 4 months ago

It still works for me:

> pip list installed | grep audiocraft
audiocraft                    1.2.0
> uname -a
Darwin josmbpro 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64
josmithiii commented 4 months ago

I just updated and it still installs ok:

> git pull
...
> pip install .
...
> pip list installed | grep audiocraft
audiocraft                    1.3.0a1

Attached is my list of installed modules in case that helps: installed.txt

zeke-john commented 4 months ago

Thank you for the info, i tried using your above suggestion using a conda environment: conda create -n env_pytorch python=3.11

now i don't get get the original error, but instead I just hangs on this: Building Docker image from environment in cog.yaml...

I am using Musicgen with replicate and cog, and this happens when i run this command to test it: cog predict -i input_text="Smooth Jazz" -i duration=100 -i extend_stride=29 -i temperature=0.75

This is my uname -a: Darwin Zekes-MacBook-Air.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:12 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8103 arm64

jeremyxie97 commented 2 weeks ago

same problems on windows, anyone solve it?