Live data from Hacker News

Using uv with PyTorch

docs.astral.sh

1–10 of 56 posts

Re: Using uv with PyTorch

#2
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.

Re: Using uv with PyTorch

#3
uv significantly speeds up my pytorch in docker builds

  # Setup virtual env
  ENV VIRTUAL_ENV=/app/.venv
  ENV PATH="$VIRTUAL_ENV/bin:$PATH"
  RUN python3 -m venv $VIRTUAL_ENV
  RUN . $VIRTUAL_ENV/bin/activate

  # install using uv
  RUN pip install uv
  RUN uv pip install torch==${TORCH_VERSION} --index-url https://download.pytorch.org/whl/cpu
The index-url makes it really convenient.

Re: Using uv with PyTorch

#4
post #3

uv significantly speeds up my pytorch in docker builds # Setup virtual env ENV VIRTUAL_ENV=/app/.venv ENV PATH="$VIRTUAL_ENV/bin:$PATH" RUN python3 -m venv $VIRTUAL_ENV RUN . $VIRTUAL_ENV/bin/activate # install using uv RUN pip install uv RUN uv pip install torch==${TORCH_VERSION} --index-url https://download.pytorch.org/whl/cpu The index-url makes it really convenient.

Use —copy-from to make it even faster, and use a cache mount

https://docs.astral.sh/uv/guides/integration/docker/#install...

Re: Using uv with PyTorch

#5

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…

I have run into multiple package problems with 3.13 with a non obvious root cause error message. Thankfully, uv makes it trivial to switch out to 3.12

Re: Using uv with PyTorch

#6

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…

I have run into multiple package problems with 3.13 with a non obvious root cause error message. Thankfully, uv makes it trivial to switch out to 3.12

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

Re: Using uv with PyTorch

#7
post #3

uv significantly speeds up my pytorch in docker builds # Setup virtual env ENV VIRTUAL_ENV=/app/.venv ENV PATH="$VIRTUAL_ENV/bin:$PATH" RUN python3 -m venv $VIRTUAL_ENV RUN . $VIRTUAL_ENV/bin/activate # install using uv RUN pip install uv RUN uv pip install torch==${TORCH_VERSION} --index-url https://download.pytorch.org/whl/cpu The index-url makes it really convenient.

Speeds up installation, or speeds up PyTorch in general?

Re: Using uv with PyTorch

#8
post #3

uv significantly speeds up my pytorch in docker builds # Setup virtual env ENV VIRTUAL_ENV=/app/.venv ENV PATH="$VIRTUAL_ENV/bin:$PATH" RUN python3 -m venv $VIRTUAL_ENV RUN . $VIRTUAL_ENV/bin/activate # install using uv RUN pip install uv RUN uv pip install torch==${TORCH_VERSION} --index-url https://download.pytorch.org/whl/cpu The index-url makes it really convenient.

Speeds up installation, or speeds up PyTorch in general?

Almost certainly only the install. Uv is basically a pip tool substitute with a few other bells and whistles too but shouldn't affect run time whatsoever.

Re: Using uv with PyTorch

#9
post #6

Earlier quoted context omitted.

I have run into multiple package problems with 3.13 with a non obvious root cause error message. Thankfully, uv makes it trivial to switch out to 3.12

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 case.

I can create an issue if it helps, but really quick here's the error I was getting and some talk on discord about it:

https://pastebin.com/UVkFstJH

https://discord.com/channels/1082332781146800168/12957237931...

Re: Using uv with PyTorch

#10
post #4
post #3

uv significantly speeds up my pytorch in docker builds # Setup virtual env ENV VIRTUAL_ENV=/app/.venv ENV PATH="$VIRTUAL_ENV/bin:$PATH" RUN python3 -m venv $VIRTUAL_ENV RUN . $VIRTUAL_ENV/bin/activate # install using uv RUN pip install uv RUN uv pip install torch==${TORCH_VERSION} --index-url https://download.pytorch.org/whl/cpu The index-url makes it really convenient.

Use —copy-from to make it even faster, and use a cache mount https://docs.astral.sh/uv/guides/integration/docker/#install...

Also use pyproject.toml to specify dependencies, not manually installing stuff with uv pip
Post reply on HN