-
Notifications
You must be signed in to change notification settings - Fork 147
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
Error in setup.py "No module named 'torch'" when installing with Poetry #156
Comments
This is a current limitation, indeed. The bad thing is that I do not think there exists a workaround for this. Any ideas? |
I would need to verify some assumptions, but I believe it is possible to strictly separate build steps from runtime installation. Perhaps instead of passing from setuptools.command.install import install
class BuildExtensionCommand(install):
def run(self):
from torch.utils.cpp_extension import BuildExtension
return BuildExtension.with_options(no_python_abi_suffix=True, use_ninja=False).run()
setup(
# ...
cmdclass={
'build_ext': BuildExtensionCommand
}
) This snippet is completely unverified though, so just the sketch of an idea. I'm not sure yet how to create the |
Thanks for digging into this. If you are interested, please feel free to contribute :) |
…dataset (rusty1s#156) * Add a generic `kumo_loader` function that can points to snowflake/s3/local dataset * Clean up code, switch test env from snowflake to s3 to save costs from CI * lint * change test data location to local
I'm confused, if |
We need to import torch in setup.py for compilation, so we cannot add it as a dependency. It needs to be installed in advance :( |
what is the consensus workaround here if there is one? |
We currently have an install script that installs torch and then these packages. After that, we run TL;DR pretty hacky. 😅 I think others may just avoid placing torch* in their |
sorry, i'm pretty new to this and also my first time responding to a github issue so forgive me if this is the wrong way to go about it. however, i'm unsure what is meant by "avoiding placing torch* in their |
@abrahme no worries, your response seems like the right way to go!
Yeah, I'd guess that's what others do. ie: the Another approach I've seen people do is hard code the URLs to pull wheels/etc from. You can specify markers so the right file is used for each OS/CPU, but you would have to just hard code the cuda version (eg: |
Thanks for the clarification. I ended up just using |
I got around the issue in the following way: (1) Configure in the .toml file the source URL where the wheels are pulled from:
Check that the parts Running the command should create the following kind of section to your .toml file.
(2) Add and install the
Now you should see this in the .toml file
...and everything should work fine. Clearly this is not a scalable solution if the repo is used by several different people with different cpu/cuda setups, but works as a temporary workaround. |
What I did was build the whls from source. Please point out any issues with this approach
|
On Mac, with @hemmokarja solution to setup a secondary source failed
with After hours of frustration, I realised by checking in the source list, that poetry was trying to fetch non-macos versions (ending with "cpu": 0.3.1+pt21cpu) Simply running |
@raphael-assal Thank you for your macOS specific remark. I know it might be asking much, but could you provide a full recipe to get it running as of today. I think poetry has changed a bit and the above content might not be up to date. At least when I try these commands, I am running into trouble. (Note also that I have an mac with Intel-CPU, so I cannot use PyTorch higher than 2.2.x.) |
If Python environment (system Python installation or in a docker image) does have
and then run
|
TL;DR try See issue python-poetry/poetry#9707 |
When I try to install
torch-sparse
using Poetry, I'm getting the following error which occurs insetup.py
:The reason is that
torch-sparse
importstorch
insetup.py
whiletorch
is not yet installed. Since thosetorch
imports are only needed to build compiled extensions, it should be possible to avoid importingtorch
when installing thetorch-sparse
wheel package.These are commands to reproduce the problem (tested using Poetry v1.1.7):
The text was updated successfully, but these errors were encountered: