-
Notifications
You must be signed in to change notification settings - Fork 577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
importing torch in setup.py will cause arcane exceptions when xformers is added without versions #940
Comments
one solution is to gracefully fail if torch is not in the build environment, because pip is running your setup.py for metadata gathering, not to build a wheel |
Yes that would be a solution. That would require a bit of refactoring of our |
Having the same problems here. I think you might get away with adding EDIT: build works if I do this:
|
you can't specify that a specific dependency should be installed without build isolation using a string in a
the only thing you import torch for is to check its version and whether cuda is available. you can achieve both without importing torch. it is a small change. another POV is that pip should be evaluating the extension build command and build requirements lazily, which would allow you to specify that torch is needed by the build process if the user actually needs to build an extension and actually import it when they do. in principle you can achieve this by modifying the |
I agree. I just wanted to point out this temporary workaround while this gets solved. Of course, the best solution is the one you describe. |
Pinging this again. Until this is fixed, xformers cannot practicably be specified as a dependency without a specific version. |
Agreed. It would simply be enough to add a [build-system]
requires = ["setuptools", "torch>={whatever}"]
build-backend = "setuptools.build_meta" You can find some references here. |
Hey there. I am working on a very small PR to address this issue. I forked the repo and you can see the commit here. I just added a [build-system]
requires = [
"setuptools",
"torch>=2.0.0"
]
build-backend = "setuptools.build_meta" As a very brief reminder, Adding this file with these 5-10 lines is enough already to start the installation project. However, a couple of errors are thrown and I think they may be due to my machine being an ARM mac. I believe they are due to 1. me not having ninja on my machine and 2. since I my laptop does not have a GPU, torch needs numpy. I wouldn't really know how to "conditionally" include those in the build-system table. Perhaps @doctorpangloss you could test building on your own machine? The following steps are needed:
|
Hi, |
Hey there, thanks for the reply.
Thanks for the explainer. Why do you say you don't think the isolated env might have a different PyTorch version? What if you just pin the necessary pytorch version in the
I am afraid I don't understand what you mean by |
The issue is that if the isolated environment will have a version of PyTorch X, xFormers will be built for PyTorch version
We would also need to pin that same version inside the |
Oh okay, I think I get it now. xformers needs to be built with the same version as the one the user has installed. |
https://github.com/facebookresearch/xformers/blame/0ec6aa244f3fbf1a077782bbf3ac8e6f2e4d1d16/setup.py#L23C5-L23C5
setup logs:
Observe
setup.py
importstorch
, but mypyproject.toml
has:aka requires does not contain torch, so your setup.py cannot import it. You will have to do something else. I understand the
import torch
line has been around since this package was authored, but it looks likepip
has changed in the meantime to start this isolation process. There will be a lot of inertia on your team around this code. Nonetheless, fixing it will probably resolve a lot of issues people are reporting.The text was updated successfully, but these errors were encountered: