astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
19.95k stars 591 forks source link

Add documentation for installing common pytorch variants #5945

Open zanieb opened 1 month ago

zanieb commented 1 month ago

😭 but it must be done!

nikhilweee commented 1 month ago

I think the most common difficulty would be to specify the index url, but I'm glad uv makes it as easy as possible.

uv add torch --index-url https://download.pytorch.org/whl/cpu # within a project
uv pip install torch --index-url https://download.pytorch.org/whl/cpu # otherwise
FishAlchemist commented 3 weeks ago

However, I've always used uv pip install for both PyTorch and TensorFlow, because on my Windows system, PyTorch uses CUDA 12.1 and TensorFlow includes tensorflow-intel, both of which are platform-dependent.

baggiponte commented 3 weeks ago

Available to help :) I am on ARM macOS and uv add torch recently has always been nice to me 😅 Regular version (w/o CUDA dependencies) are installed.

baggiponte commented 3 weeks ago

Would also like to point out there's been this python package (recently recommended by @muellerzr, HuggingFace Accelerate maintainer) to install torch with automatic backend detection. Might be a good candidate for a first uv plugin, I guess?

valentincalomme commented 3 weeks ago

Sharing my thoughts to help with the discussion.

I feel that the biggest challenge here is that the source is platform dependent. On MacOs, PyPi is sufficient. But for Linux and Windows, if one wishes to install a cuda enabled version, they need to specify a URL.

I would personally already be helped if I could specify platform-dependent sources for packages.

Now the cuda/not cuda question is difficult. I think that theoretically, using optional dependencies can be a way to deal with this. If you want the cuda version (for any platform), install it as my_package[cuda]. If you only need the cpu version (i.e. Github actions), then install it as my_package[cpu].

But it's more of a flag then an optional dependency. It's either/or. So not sure how to deal with that. Maybe there can be "modes" for dependencies, with a default. And if the "cuda" mode is specified, dependencies are installed based on that.

zanieb commented 3 weeks ago

I would personally already be helped if I could specify platform-dependent sources for packages.

Regarding this.. https://github.com/astral-sh/uv/issues/3397

zanieb commented 2 days ago

Example at https://github.com/astral-sh/uv/issues/7245#issuecomment-2340970983