Live data from Hacker News

Using uv with PyTorch

docs.astral.sh

41–50 of 56 posts

Re: Using uv with PyTorch

#41

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 trac…

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.

Does pip-compile do the same? Or what's the difference?

Re: Using uv with PyTorch

#42

Earlier quoted context omitted.

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.

Does pip-compile do the same? Or what's the difference?

pip-compile, poetry, Pipenv, et al all try do roughly the same, with various caveats and design differences (e.g. Pipenv is not meant to be used in libraries, only applications). uv is the latest kid in the block.

Re: Using uv with PyTorch

#43

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 trac…

One reason is that it is not just for project venv/deps management but can replace other tools like pipx and pyenv for most scenarios.

Re: Using uv with PyTorch

#44
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).

How does uv compare in this regard?

Re: Using uv with PyTorch

#45
post #32

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…

I haven’t used Conda since 2021 but recall it had a SAT solver that was very slow especially on degenerate cases. How does uv’s sat solver compare?

There are such cases in uv as well, and I’ve hit them quite often when I didn’t specify lower bounds (especially for boto3).

Re: Using uv with PyTorch

#47

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 trac…

PS: one thing I like about my current workflow is no extra tools needed, base python install is all that‘s required.

It’s similar with uv. You have exactly one dependency on the host system – it’s just uv instead of Python. uv will then obtain the correct version of Python for your project. And uv is easier to install than Python – it’s literally just one binary.

Re: Using uv with PyTorch

#48
post #18

Earlier quoted context omitted.

uv python install 3.xx

That is not global. From the uv getting started docs: "When Python is installed by uv, it will not be available globally (i.e. via the python command). Support for this feature is planned for a future release. In the meantime, use uv run or create and activate a virtual environment to use python directly." So yes, one needs mise/asdf/pyenv or similar for global installs for now.

You could always just `alias python="uv run python"`

Re: Using uv with PyTorch

#49
post #32

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…

I haven’t used Conda since 2021 but recall it had a SAT solver that was very slow especially on degenerate cases. How does uv’s sat solver compare?

Conda has a faster solver, as of 2022

https://www.anaconda.com/blog/a-faster-conda-for-a-growing-c...

Re: Using uv with PyTorch

#50
post #6

Earlier quoted context omitted.

I work on our error messages, feel free to open an issue and we'll do our best to make it clearer

Hey there, I experienced a hairy error message recently too while trying to install aider-chat from pypi with Python 3.13 and Pixi (but I was told the error was coming from UV). "Solution": `pixi add python=3.12`, then `pixi add --pypi aider-chat` succeeds without issues. A message like "aider-chat seems to be incompatible with python=3.13, try downgrading to python-3.12" would be great, assuming this is really the c…

Thanks! There's definitely room for improvement there. I'll see what we can do — in general it's a bit of an arcane task to extract clear suggestions from the resolver's error tree.
Post reply on HN