-
Notifications
You must be signed in to change notification settings - Fork 624
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
base: main
Are you sure you want to change the base?
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. |
@baggiponte I'm a bit worried this could be confusing, since it assumes the user hasn't given PyTorch package indexes to uv anywhere. However, this thing was never explicitly mentioned in the narrative. I'm unsure whether it's a good idea to imply it As for the [tool.uv.sources] issue, it's just that I personally don't know how to use it to make PyTorch's lock files cross-platform. Therefore, I'm not sure if the current uv can make PyTorch cross-platform through it. @zanieb Can the current UV create cross-platform lockfiles for projects that depend on PyTorch? |
I think this might be unblocked by #7481 or some of the work following that. |
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).