我正在研究稳定扩散并尝试安装 xformers 来训练我的 Lora。
我的电脑是Macbook M2 Max并且已经安装了最新的python3.11和pip 23.1.2
which python3
/Library/Frameworks/Python.framework/Versions/Current/bin/python3
python3 -V
Python 3.11.3
which pip3
/Library/Frameworks/Python.framework/Versions/Current/bin/pip3
pip3 -V
pip 23.1.2 from /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip (python 3.11)
但是每次我使用下面的cmd时:
pip3 install xformers
我会收到如下消息:
Collecting xformers
Using cached xformers-0.0.20.tar.gz (7.6 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
╰─> [21 lines of output]
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/3.11/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 "/Library/Frameworks/Python.framework/Versions/3.11/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/05/3wghcmr93436gfgb3ty5mnmm0000gn/T/pip-build-env-3da38ps7/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/05/3wghcmr93436gfgb3ty5mnmm0000gn/T/pip-build-env-3da38ps7/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
self.run_setup()
File "/private/var/folders/05/3wghcmr93436gfgb3ty5mnmm0000gn/T/pip-build-env-3da38ps7/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 488, in run_setup
self).run_setup(setup_script=setup_script)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/05/3wghcmr93436gfgb3ty5mnmm0000gn/T/pip-build-env-3da38ps7/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 338, 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.
我已经使用官方网站的命令安装了PyTorch:
pip3 install torch torchvision torchaudio
当我使用下面的代码运行 test.py 时:
import torch
x = torch.rand(5, 3)
print(x)
我会得到正确的结果如下:
python3 a.py
tensor([[0.8204, 0.4140, 0.5262],
[0.1857, 0.3604, 0.3496],
[0.0620, 0.2303, 0.1033],
[0.8081, 0.2826, 0.2922],
[0.1685, 0.5701, 0.9935]])
表示割炬已正确安装。
我还可以使用 pip3 list 看到 torch
torch 2.0.1
torchaudio 2.0.2
torchvision 0.15.2
我还使用清除了所有 pip3 缓存
pip cache purge
这不起作用。
我也重启电脑,也没用。
我看到很多问答都在谈论conda,我还没有安装conda所以我相信这应该不是conda相关的问题。
如何解决这个问题?谢谢~
我安装旧版本
pip install transformers==2.5.1
然后我安装
pip install transformers
它对我有用,但不知道为什么