pytorch / torchchat

Run PyTorch LLMs locally on servers, desktop and mobile
BSD 3-Clause "New" or "Revised" License
3.09k stars 192 forks source link

Can't install requirements when using Python-3.12 #963

Open malfet opened 1 month ago

malfet commented 1 month ago

🐛 Describe the bug

pip install fails because it could not find torch even though, it's present in the environment:

% pip install git+https://github.com/pytorch/ao.git@d36de1b144b73bf753bd082109c2b5d0141abd5b 
Collecting git+https://github.com/pytorch/ao.git@d36de1b144b73bf753bd082109c2b5d0141abd5b
  Cloning https://github.com/pytorch/ao.git (to revision d36de1b144b73bf753bd082109c2b5d0141abd5b) to /private/var/folders/rk/fxg20zvx6vvb5bk7cplq4xrc0000gn/T/pip-req-build-r05jkt6n
  Running command git clone --filter=blob:none --quiet https://github.com/pytorch/ao.git /private/var/folders/rk/fxg20zvx6vvb5bk7cplq4xrc0000gn/T/pip-req-build-r05jkt6n
  Running command git rev-parse -q --verify 'sha^d36de1b144b73bf753bd082109c2b5d0141abd5b'
  Running command git fetch -q https://github.com/pytorch/ao.git d36de1b144b73bf753bd082109c2b5d0141abd5b
  Running command git checkout -q d36de1b144b73bf753bd082109c2b5d0141abd5b
  Resolved https://github.com/pytorch/ao.git to commit d36de1b144b73bf753bd082109c2b5d0141abd5b
  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/nshulga/py3.12-torch2.4/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/nshulga/py3.12-torch2.4/lib/python3.12/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/nshulga/py3.12-torch2.4/lib/python3.12/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/rk/fxg20zvx6vvb5bk7cplq4xrc0000gn/T/pip-build-env-x_bm22ut/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/rk/fxg20zvx6vvb5bk7cplq4xrc0000gn/T/pip-build-env-x_bm22ut/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/rk/fxg20zvx6vvb5bk7cplq4xrc0000gn/T/pip-build-env-x_bm22ut/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 497, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/private/var/folders/rk/fxg20zvx6vvb5bk7cplq4xrc0000gn/T/pip-build-env-x_bm22ut/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
          exec(code, locals())
        File "<string>", line 31, in <module>
      ModuleNotFoundError: No module named 'torch'
      [end of output]

Versions

CI

malfet commented 1 month ago

But I found a workaround

pip install setuptools wheel
pip install --no-use-pep517 git+https://github.com/pytorch/ao.git@d36de1b144b73bf753bd082109c2b5d0141abd5b
larryliu0820 commented 1 month ago

@msaroufim I wanted to raise this issue earlier but it slipped - what is the best way to install ao nightly on mac? It doesn't look like there's a nightly wheel under this URL: https://download.pytorch.org/whl/nightly/torchao-nightly/, that's why we have to pull from git and build from source. This can be avoided if we have ao nightly prebuilt for mac.

msaroufim commented 1 month ago

We don't have mac binaries right now but it's something we could use help with, we leverage some workflows from dev infra and those are a bit opaque to me https://github.com/pytorch/ao/blob/main/.github/workflows/build_wheels_linux.yml

msaroufim commented 1 month ago

Update So we now have m1 support for our release binaries, as of today this 0.4 which I pushed manually. Not planning on adding nightly support until we figure out automation