-
Notifications
You must be signed in to change notification settings - Fork 962
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
docs: Add PyTorch installation guide #6523
docs: Add PyTorch installation guide #6523
Conversation
Have you considered including a way to specify package versions? |
Like |
This will definitely require validation from folks on other platforms. Thanks for starting though! |
On macOS, packages are obtained directly from PyPI, thus eliminating the need for local version identifiers. |
Exactly! That's what I wrote on the macOS section. Sorry if I wasn't being clear. I realised I can test this out on Colab for Linux 😈
Then:
|
Have uv considered adding the index-url to the pyproject.toml file when using uv add? uv add --extra-index-url=https://download.pytorch.org/whl/cu121 torch torchvision torchaudio --no-sync
uv add deep-translator |
@FishAlchemist yes, it's on the roadmap #171 |
@zanieb |
1eb215b
to
94a6c95
Compare
Uh yeah, just pushed a commit to remove all the mentions to modifying So:
|
@baggiponte For PyTorch, I still recommend including the specific version in the documentation. I remember seeing some issues in the past where problems only occurred when a specific version was specified, and I'm not sure if they have been fixed. |
Do you think I should try and/or cover some of those?
Uhm, I guess this deserves an issue of its own?
Were those issues uv-related or just generic torch version problems? Because otherwise I would not be super inclined to add this kind of recommendation to the docs. Unrelated: perhaps I could create a new repo and use github actions on various runners to see if everything works, if we need more complex installation tests. |
@baggiponte If lock file doesn't have a mac wheel, I'm unsure if Command (uv 0.3.3 (deea602 2024-08-23))uv init torch_uv -p 3.10
# Remember to enter the directory
uv python pin 3.10
uv add --extra-index-url=https://download.pytorch.org/whl/cu121 torch --no-sync Note: Create on windows 11 (x86-64) Part of uv.lock for torch
According to the document:
If a uv.lock generated on Windows cannot be used on other platforms, then it is not a uv.lock as documented. |
@baggiponte pipuv pip |
Hey there, was away for the weekend. Thank you very much for the explanation 😊 Will get back to this after work, later today. In the meanwhile, to recap:
Did I get everything? Thank you again for taking the time to steer me through this! |
While this is generally correct, there's a potential issue when using uv add to install PyTorch. Note: Since PyPI's PyTorch offers wheels for macOS, Linux, and Windows, if we switch the source to PyPI and remove the Local version identifiers, there will be no errors. However, the version will possibly switch from CUDA to CPU only. You're welcome. I know how frustrating these issues can be, so I wanted to save other users some time. |
It's pretty annoying since somehow |
@inflation there are details on that behavior in the documentation. Please don't complain about it in someone's pull request. |
This is precisely where it happens the most. Installing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 from the PyTorch side!
docs/guides/integration/pytorch.md
Outdated
|
||
* If want PyTorch on macOS, just run `uv add torch`/`uv pip install torch`. | ||
* If want PyTorch on Windows *with CPU support*, just run `uv add torch`/`uv pip install torch`. | ||
* If want to install PyTorch on Linux with CPU support, add `--extra-index-url=https://download.pytorch.org/whl/cpu` to the `uv add`/`uv pip install` command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we be able to do this with --index-url
instead of --extra-index-url
throughout?
The extra version of this flag was the cause of a bad security event already for PyTorch and we would not want to repeat that here: https://pytorch.org/blog/compromised-nightly-dependency/
Because we do use --index-url
for all the pip commands, you can rely on the fact that the url will contain all depedencies needed to install torch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note we have different behavior than pip to try to avoid such issues https://docs.astral.sh/uv/pip/compatibility/#packages-that-exist-on-multiple-indexes
I think the real answer is that we need #171 though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, he has a point. I'll add a link to explain this behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree the default is better. But it still sounds quite dangerous if we make a mistake (don't realize we forgot to push a version of that package on our index). Looking forward to the pinned package index!
Thanks for the update.
94a6c95
to
283d193
Compare
Hello there! Sorry for disappearing, but as if it was not enough already, we got a sparkle of floods here too. I edited a couple of things with the last commit I pushed.
@zanieb let me know if it makes sense, suggest edits or make them directly. |
@baggiponte |
Makes perfect sense! I guess it might be a good idea to mention that you should add |
According to the documentation, version 0.4.10, [tool.uv.sources] only supports these sources. I'm trying to use extra-index-url, but as a result, there are no macOS wheels available. [tool.uv]
extra-index-url = ["https://download.pytorch.org/whl/cu121"] I've yet to find a solution for using [tool.uv.sources] that can support Windows, Linux, macOS, and CUDA. |
283d193
to
2556d40
Compare
Very clear. Pushed another minor edit mentioning this. Would love to hear your feedback on the phrasing. |
I also added torchvision to the example in the docs given #8344. |
I believe that @charliermarsh plans to look into PyTorch this month so I've assigned him. Great to see all the collaboration here! |
I'm running into the same original issue as #7202 following these docs (the "Distribution .. can't be installed because it doesn't have a source distribution...") error. My setup: workspace pyproject.toml:
And
Trying to run
|
@vvuk -- Are you running on macOS or non-macOS (per the markers)? |
non-macos (Windows). I've also noticed some docs (e.g. here) have
So looks like there was only a resolution for linux-aarch64 and for macos-arm64 |
That's discussed at length in a few places: #5182 (comment), #8536 (comment). (There's no way for us to know if the set of wheels covers the entire space you care about.) |
You probably need to define your dependencies like:
Confusingly, the wheels you want from the PyTorch index are tagged as |
Yeah, I was hoping to not have to declare explicit versions; that seems to be the only workable solution though. Maybe one way to resolve this mess would be a uv config for "prioritize these local tags in this order for resolution". e.g.:
To state that on non-macos, prioritize |
Yeah, it's not a great situation. I'd really love to just fix / improve the local version handling entirely. |
I'm trying with this in my workspace pyproject.toml:
A workspace member has a dependency on just
okay, I can believe there's no cuda version for aarch64. I've tried every variant I can think of and can't get a resolution, including this which I think should 100% work:
I get:
If I do |
This seems to be an interaction with dependency overrides and sources; it seems like
and don't put that in override-dependencies, and keep the uv sources to point to the cpu repo for non-windows, I can resolve. If I make dependencies generic ("torch", "torchaudio", "torchvision") and restore the overrides, I get the same error about not being able to resolve +cu124. ... but if I do this (dependencies), then I'm back to a non-virtual workspace, and then I run into #5727. So, I created a dummy |
I am missing the following use cases in the docs:
And perhaps it would be nice to have some sort of FAQ section with common mistakes, for instance the docs specify in the beginning |
Perhaps a useful example #8746 (comment) |
Hi everyone, Operating Systemshttps://github.com/pytorch/pytorch/blob/main/RELEASE.md#operating-systems Release Compatibility Matrixhttps://github.com/pytorch/pytorch/blob/main/RELEASE.md#release-compatibility-matrix |
Co-authored-by: Santiago Castro <bryant1410@gmail.com>
Now that we have all the pieces in place I'm going to invest in comprehensive PyTorch docs. I will fold this work into those docs -- thank you so much for writing it up. I may even merge this first, then make my PR atop it so that this is preserved. |
(These docs are really great, thank you @baggiponte.) |
Hello there! First real docs PR for uv.
integrations
since Charlie added the FastAPI integration there.Summary
Addresses #5945
Test Plan
I just looked at the docs on the dev server of mkdocs if it looked nice.
I could not test the commands that I wrote work outside of macOS. If someone among contributors has a Windows/Linux laptop, it should be enough, even for the GPU-supported versions: I expect the installation will just break once torch checks for CUDA (perhaps even at runtime).