-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
pytorch and poetry #4231
Comments
[tool.poetry.dependencies]
torch = { version = "=1.9.0+cu111", source = "pytorch" }
torchvision = { version = "=0.10.0+cu111", source = "pytorch" }
[[tool.poetry.source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu111/"
secondary = true This works for me with poetry |
this is my
with this I get the following error (with
and if I put both torch and torchvision in comments I still get the following error:
|
This is a duplicate of #2543, #3855, #3306 and some others. An ugly workaround while this is not fixed is:
|
@scherzocrk when I "poetry install", the torch will be " • Updating torch (1.9.0+cu111 -> 1.9.0)" |
@wangm23456 I wrote the hack above using the task-runner, I have the same issue, poetry always rolls back to regular torch. It gets me crazy.. |
Just tested it on v1.2.0a2 and with the secondary source poetry install is still very slow and takes more than 18m in my machine. |
Also worse than not being able to install
|
Coming back half a year later it seems there is still no solution for Pytorch related packages in poetry. Will this ever get solved? Otherwise need to move to other solutions. |
yeah, about that. I want to add this functionality, so my team can use poetry. Otherwise, we'll stick to conda, which is not optimal, bc poetry plays so well with CI & CD pipelines, espescially for packaging software |
Yeah, we unfortunately had to decide now to move away from poetry to good old pipenv. Let's hope there will be a solution as some point for poetry. |
@psinger here is the good news for you. I just tested with poetry version
|
@Kavan72 thx for the update, it works. However the dependencies resolving time is absolutely huge (600+ seconds), would it be possible to ignore dependency solving for a package, or hard code the dependencies so that poetry doesn't have to full scan a 1.5Go package ? |
The solution of @Kavan72 is cool but unfortunately still a work around as you need to target a specific python version, and OS which goes against the whole idea of Poetry. |
@kikohs I ended up using poe the poet as a task runner too in the end. To avoid rolling back to cpu torch, you have to install every torch-using lib with pip through the task-runner too (e.g. transformers) |
This issue is blocking "unlocking the poetry" potentials when it comes to leveraging poetry in the stack that uses PyTorch and its ecosystem. I have tried with following:
but the default
As mentioned in this ticket, #4704 this is a known issue. However, amongst all possible ways to address this issue, this solution of using secondary sources seems to be the ideal fix for the issue in question. As a short-term interim, I have also tried platform and version-specific settings. This would work fine if PyTorch was my leaf dependency. Because my setup involves using PyTorch, Torchvision, and Pytorch lightening. Because more dependencies rely on PyTorch, just specifying torch wheels in toml fails to solve the dependency:
Error:
I have been in knots with this one, particularly because there are so many issues open around this issue: The only solution that works cross-platform is https://github.com/nat-n/poethepoet but that is not a great solution either (not lining up with lock file, not using same cache etc, the need for additional pip run!). It would be great if we can fix this issue. (this is a duplicate comment from #4704 (comment), posting again as this is very relevant ticket again) |
Thanks for the detailed post @suneeta-mall. I want to try and break out targetted improvements to help with the pytorch use case being better supported. Let me try and addres a few things in your post with that intent.
This is expected in that Also see #4704 (comment). Regarding the local build tag resolving issue, the I suspect this is the same as being taked about in #4729 (comment). That, in theory atleast, should fix this issue. From the Poetry side once the local tag solving is fixed, I suspect things will improve. If that is not the case please do let me know. For those working with the PyTorch community, if you can work with the PyTorch team to get the following added/fixed, your experience when using PyTorch with Poetry might be improved.
PS: One could in theory generate and host files required for 1 and 2 using a CI/CD job + vercel/fastly etc with some packaging code if so motivated. The links can still retain the upstream file link, but with sha256 appended and a new |
I am using mac for local development and a docker for publishing. The following allowed me to use a single pyproject file for both, hope it will help someone:
python version 3.10.6 |
Thanks @chanansh for that answer. However, to make it succssfully install on my mac with an M1 Pro chip, I had to change the Also, note that it would fail to install on both the docker container and mac if I used python version |
Here is a copy:
You can find all wheel URLs at either one of You can find your current platform and architecture by using Python command:
You can find the list of |
Add an update: After upgrading to latest Poetry 1.3.1, I can simply use this now: [tool.poetry.dependencies]
python = "3.10.x"
torch = "1.13.1" It succeed both on both my MacBook Pro with M1 chip and Linux (Ubuntu) in the pipeline. (I did regenerate Here is the pyproject.toml. For Linux (Ubuntu) in the pipeline part, you can see this which shows succeed: |
@hongbo-miao I tried upgrading to Poetry 1.3.1, editing my pyproject.toml file as described, and then running
|
With poetry==1.3.2 on python 3.9.15 in docker
Updating to poetry==1.4.0 fixed it ! EDIT: and I ended up using torch = [
{ url = "https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp39-cp39-linux_x86_64.whl", markers = "sys_platform == 'linux' and platform_machine != 'aarch64'"},
{ url = "https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp39-cp39-linux_x86_64.whl", markers = "sys_platform == 'darwin' and platform_machine != 'arm64'"},
{ url = "https://download.pytorch.org/whl/cpu/torch-1.13.1-cp39-none-macosx_11_0_arm64.whl", markers = "sys_platform == 'darwin' and platform_machine == 'arm64'"},
{ url = "https://download.pytorch.org/whl/torch-1.13.1-cp39-cp39-manylinux2014_aarch64.whl", markers = "sys_platform == 'linux' and platform_machine == 'aarch64'"},
] |
I still have this issue. |
confirming issue still exists |
The below resolves in a few seconds with
If I remove torchvision and downgrade to
Updating from
|
Not sure if it is relevant, but I also had issues with setuptools being removed in my anaconda+poetry environment. Updating anaconda with |
I think @cateseale is correct. For people failed to install PyTorch by Poetry after May 9, 2023. So instead of using
This should work:
Hopefully next PyTorch version will fix this issue. 😃 |
Is this getting a fix? |
Just commenting to confirm that its still a problem. I use a Docker container with a Torch/Cuda env that shouldnt be touched and If I specify Is there any solution to use the pre-isntalled version? (I need to fix it in the |
I'm confused how this remains an issue... shouldn't the newer version just take care of this? |
Yes it's broken again for me Its started failing again with the release of torch 2.1 - poetry and pip install different things again
but nvidia-nvtx-cu12, So It works fine when I specifically target |
@david-waterworth I am confused.
If the current version is 2.1.0 - isn't that what it is likely to try to use - thus avoiding the 2.0.1 problem? Or does it still happen? |
Sorry I wasn't clearm yes it's trying to use 2.1.0 which is also broken. There's an issue with the torch packaging, which results in the metadata for dependencies not being correctly uploaded to PyPi (as I understand it). Both 2.0.1 and 2.1.0 are affected so cannot be installed with poetry. setting torch = {version = ">=2.0.0, !=2.0.1, !=2.1.0"} prevents the poetry failure, and 2.1.1 is apparently being prepared to fix the problem on the torch side. |
any better solution than #4231 (comment) |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).Issue
pytorch is now pep503 compliant (pytorch/pytorch#25639 (comment)) but I still can't add torch and torchvision.
I've tried using this:
but got this:
and if I try using
I end up disabling the pypi and can't download anything else...
The text was updated successfully, but these errors were encountered: