TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Using uv with PyTorch

170 pointsby charliermarsh6 months ago

12 comments

kolja0056 months ago
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&#x27;m bummed I have to use Poetry at work after having watched this talk.<p>[1] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=gSKTfG1GXYQ" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=gSKTfG1GXYQ</a><p>edit: NP-complete not NP-hard
评论 #42191993 未加载
thundergolfer6 months ago
Kind of an aside as this doc is about the complexities of installing particular PyTorch versions, but will say that uv is <i>way</i> faster at installing PyTorch than pip.<p>We run internal benchmarks of our custom container image builder and in the &#x27;install torch&#x27; benchmark the p50 time saved when using `uv` is 25 seconds! (71.4s vs. 43.74s)<p>---<p>Aside 2: Seems there&#x27;s a missing &quot;involves&quot; in this sentence: &quot;As such, installing PyTorch typically often configuring a project to use the PyTorch index.&quot;
评论 #42191116 未加载
gdiamos6 months ago
uv significantly speeds up my pytorch in docker builds<p><pre><code> # Setup virtual env ENV VIRTUAL_ENV=&#x2F;app&#x2F;.venv ENV PATH=&quot;$VIRTUAL_ENV&#x2F;bin:$PATH&quot; RUN python3 -m venv $VIRTUAL_ENV RUN . $VIRTUAL_ENV&#x2F;bin&#x2F;activate # install using uv RUN pip install uv RUN uv pip install torch==${TORCH_VERSION} --index-url https:&#x2F;&#x2F;download.pytorch.org&#x2F;whl&#x2F;cpu </code></pre> The index-url makes it really convenient.
评论 #42189326 未加载
评论 #42190557 未加载
评论 #42189506 未加载
pcwelder6 months ago
I just want to thank people behind uv. The tool is just amazing for development, packaging and running packages. And it&#x27;s blazing fast!
minimaxir6 months ago
So uv caused a bit of an issue with me installing PyTorch over the weekend.<p>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&#x27;s compatable with Python 3.13! This resulted in very confusing errors. (Solution was to point to the Nightly index)<p>That&#x27;s technically PyTorch&#x27;s fault, but it&#x27;s indicitave why a specific page on installing PyTorch is necessary, and it&#x27;s good to know the documentation specifically calls it out.
评论 #42191635 未加载
评论 #42189345 未加载
breuleux6 months ago
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.<p>The pace of development on uv is really impressive.
mrbonner6 months ago
Does uv support global Python install now? I need something like Mise for this.
评论 #42192371 未加载
评论 #42194345 未加载
评论 #42191001 未加载
chocolight6 months ago
I&#x27;ve read that Torch was dropping their Conda support, but won&#x27;t everybody just move to Mamba which is a drop-in replacement of Conda?<p>Conda (and Mamba) allows to avoid duplicating packages on the disk between environments (not just the downloaded archives, but the resulting expanded files too).<p>How does uv compare in this regard?
alex_suzuki6 months ago
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?<p>One limitation I know of are the inability to detect stale packages.<p>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?
评论 #42192507 未加载
评论 #42198294 未加载
评论 #42192436 未加载
评论 #42192711 未加载
antman6 months ago
Does anyone succeed in packaging a uv pytorch env to a pyinstaller exe or similar? I am having a hard time but I assume it can be automated
Mxbonn6 months ago
Now that PyTorch is also ending their anaconda package distribution, I think a lot of ml&#x2F;ds people should give uv a shot.
评论 #42192241 未加载
paradite6 months ago
I was just getting used to pipenv and pyenv combo.<p>Is this worth switching to?
评论 #42191833 未加载
评论 #42191442 未加载
评论 #42191409 未加载
评论 #42192347 未加载
评论 #42192248 未加载