I recently watched a talk by the author of uv that was surprisingly fascinating [1]. He goes into a few of the more notable hacks that they had to come up with to make it as fast as it is. The most interesting thing for me was that package resolution in python given constraints defined (eg. in requirements.txt) maps to a boolean satisfiability problem which is NP-complete. So uv uses a custom SAT solver to do this. I totally under-appreciated how much goes into this software and I'm bummed I have to use Poetry at work after having watched this talk.
Kind of an aside as this doc is about the complexities of installing particular PyTorch versions, but will say that uv is way faster at installing PyTorch than pip.
We run internal benchmarks of our custom container image builder and in the 'install torch' benchmark the p50 time saved when using `uv` is 25 seconds! (71.4s vs. 43.74s)
---
Aside 2: Seems there's a missing "involves" in this sentence: "As such, installing PyTorch typically often configuring a project to use the PyTorch index."
Joining your aside to tout the benefits of uv. We use uv combined with a simple proxy I wrote, to cache python dependencies, and then install them in parallel. UV also makes it simple to regenerate a requirements file and know who requires the dependencies, which in turn makes it easy to manage the ecosystem, analyze packages, and determine if we can reduce our footprint.
Between that latter feature, the proxy, the parallelization we've reduced build times across ~100 engineers by a solid 10 minutes. There are other things we do as well, but uv is a must have nowadays.
So uv caused a bit of an issue with me installing PyTorch over the weekend.
When installed with brew on my MacBook, uv currently has PyTorch 3.13 as a dependency, which is fine. But PyTorch does not currently have a stable wheel that's compatable with Python 3.13! This resulted in very confusing errors. (Solution was to point to the Nightly index)
That's technically PyTorch's fault, but it's indicitave why a specific page on installing PyTorch is necessary, and it's good to know the documentation specifically calls it out.
I was trying to figure out how to set up a pyproject with uv that could support cuda, rocm and other device types this morning, and next thing I knew, there was a new release adding pretty much exactly what I needed.
The pace of development on uv is really impressive.
I've read that Torch was dropping their Conda support, but won't everybody just move to Mamba which is a drop-in replacement of Conda?
Conda (and Mamba) allows to avoid duplicating packages on the disk between environments (not just the downloaded archives, but the resulting expanded files too).
In a nutshell, what do I gain from switching to uv from my current workflow, which is:
1) create a venv (`python3.xx -m venv venv`)
2) install packages from a requirements.txt into that venv?
One limitation I know of are the inability to detect stale packages.
Apart from „blazing fast“, which I‘m not convinced it really matters to me as I rarely touch the dependencies, what are the main reasons why uv is gaining traction?
You get correct version resolution (checking compatibility across the entire tree of deps-of-deps, including against different Python versions) and a lock file which represents a global state of the entire tree and gives you reproducibility of a working setup.
No need to activate venvs and the almost inevitable Python pathing "murder mysteries". uv installs in venvs first, and only then someplace else (e.g., globally).
No more clunky typing `python -m pip install foo` even when you have activated your venv (or you think you have). `uv pip install foo` is nicer and easier to remember.
uv add will add new dependencies to your pyproject.toml so you don't have to.
uv can setup skeletons for new projects in a nice, modern way
For older projects, you can have uv to resolve dependencies as of a certain date. I imagine this is great for older projects, especially with numerous dependencies.
It might remove the need for pyenv or the need to rely on your system provided Python, since uv can install Python for your project.
Cross-platform lock files
I've just started looking in to uv, so maybe my list isn't complete/very good. Some down sides include, it's still green (has some bugs naturally and lacks some features) and some might not trust/like that it's VC backed.
I would also say absolutely. We've been using pipenv for ~6 years and have managed to build a pretty good workflow around it. But uv is just _so much faster_. So we've started moving everything over to uv and I don't think we'll ever look back.
Migrating is not super hard, we wrote a small script that moves all the information from a Pipfile to a pyproject.toml and it works like a charm.
kolja005|1 year ago
[1] https://www.youtube.com/watch?v=gSKTfG1GXYQ
edit: NP-complete not NP-hard
wenc|1 year ago
How does uv’s sat solver compare?
thundergolfer|1 year ago
We run internal benchmarks of our custom container image builder and in the 'install torch' benchmark the p50 time saved when using `uv` is 25 seconds! (71.4s vs. 43.74s)
---
Aside 2: Seems there's a missing "involves" in this sentence: "As such, installing PyTorch typically often configuring a project to use the PyTorch index."
cik|1 year ago
Between that latter feature, the proxy, the parallelization we've reduced build times across ~100 engineers by a solid 10 minutes. There are other things we do as well, but uv is a must have nowadays.
gdiamos|1 year ago
orf|1 year ago
https://docs.astral.sh/uv/guides/integration/docker/#install...
ttyprintk|1 year ago
samtheprogram|1 year ago
pcwelder|1 year ago
minimaxir|1 year ago
When installed with brew on my MacBook, uv currently has PyTorch 3.13 as a dependency, which is fine. But PyTorch does not currently have a stable wheel that's compatable with Python 3.13! This resulted in very confusing errors. (Solution was to point to the Nightly index)
That's technically PyTorch's fault, but it's indicitave why a specific page on installing PyTorch is necessary, and it's good to know the documentation specifically calls it out.
the_mitsuhiko|1 year ago
0cf8612b2e1e|1 year ago
breuleux|1 year ago
The pace of development on uv is really impressive.
mrbonner|1 year ago
cbenz|1 year ago
Or via the global "python-preference" option set to "only-system".
Cf https://docs.astral.sh/uv/concepts/python-versions/#adjustin... and https://docs.astral.sh/uv/reference/settings/#python-prefere...
zanie|1 year ago
The work can be tracked in https://github.com/astral-sh/uv/issues/6265
shlomo_z|1 year ago
chocolight|1 year ago
Conda (and Mamba) allows to avoid duplicating packages on the disk between environments (not just the downloaded archives, but the resulting expanded files too).
How does uv compare in this regard?
alex_suzuki|1 year ago
One limitation I know of are the inability to detect stale packages.
Apart from „blazing fast“, which I‘m not convinced it really matters to me as I rarely touch the dependencies, what are the main reasons why uv is gaining traction?
reubenmorais|1 year ago
infamia|1 year ago
No need to activate venvs and the almost inevitable Python pathing "murder mysteries". uv installs in venvs first, and only then someplace else (e.g., globally).
No more clunky typing `python -m pip install foo` even when you have activated your venv (or you think you have). `uv pip install foo` is nicer and easier to remember.
uv add will add new dependencies to your pyproject.toml so you don't have to.
uv can setup skeletons for new projects in a nice, modern way
For older projects, you can have uv to resolve dependencies as of a certain date. I imagine this is great for older projects, especially with numerous dependencies.
It might remove the need for pyenv or the need to rely on your system provided Python, since uv can install Python for your project.
Cross-platform lock files
I've just started looking in to uv, so maybe my list isn't complete/very good. Some down sides include, it's still green (has some bugs naturally and lacks some features) and some might not trust/like that it's VC backed.
alex_suzuki|1 year ago
imjonse|1 year ago
antman|1 year ago
Mxbonn|1 year ago
nickysielicki|1 year ago
paradite|1 year ago
Is this worth switching to?
silvester23|1 year ago
Migrating is not super hard, we wrote a small script that moves all the information from a Pipfile to a pyproject.toml and it works like a charm.
jpalomaki|1 year ago
Now I have switched to uv with new projects. No problems so far. I definitely recommend giving it a go.
baggiponte|1 year ago
cbenz|1 year ago
fernandotakai|1 year ago
unknown|1 year ago
[deleted]