←back to thread

Using uv with PyTorch

(docs.astral.sh)
167 points charliermarsh | 2 comments | | HN request time: 0.523s | source
Show context
gdiamos ◴[] No.42189027[source]
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.
replies(3): >>42189326 #>>42189506 #>>42190557 #
1. samtheprogram ◴[] No.42189506[source]
Speeds up installation, or speeds up PyTorch in general?
replies(1): >>42190362 #
2. gleenn ◴[] No.42190362[source]
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.