Skip to content

Moving to uv to enable dependency override and cleaner locks #587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea
target
.venv/
backends/python/server/.venv
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea
target
.venv
backends/python/server/.venv
18 changes: 10 additions & 8 deletions Dockerfile-intel
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ COPY backends backends
COPY backends/python/server/text_embeddings_server/models/__init__.py backends/python/server/text_embeddings_server/models/__init__.py
COPY backends/python/server/pyproject.toml backends/python/server/pyproject.toml

RUN python -m pip install torch==2.6.0 torchvision torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cpu --no-cache-dir

RUN cd backends/python/server && \
make install
make install-cpu

FROM vault.habana.ai/gaudi-docker/1.19.0/ubuntu22.04/habanalabs/pytorch-installer-2.5.1:latest AS hpu
ENV HUGGINGFACE_HUB_CACHE=/data \
Expand All @@ -98,8 +96,13 @@ COPY backends backends
COPY backends/python/server/text_embeddings_server/models/__init__.py backends/python/server/text_embeddings_server/models/__init__.py
COPY backends/python/server/pyproject.toml backends/python/server/pyproject.toml

# Re-override some deps uv cannot handle them because they are
# git compiled versions.
RUN cd backends/python/server && \
make install
pip install -U pip uv && \
uv venv && \
cp -r /usr/local/lib/python3.10/dist-packages/* /usr/src/backends/python/server/.venv/lib/python3.10/site-packages/ && \
make install-hpu

FROM intel/intel-extension-for-pytorch:2.6.10-xpu AS xpu

Expand All @@ -115,9 +118,6 @@ RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRO

RUN apt-get update && apt install -y intel-basekit cmake python3-dev ninja-build pciutils
WORKDIR /usr/src
RUN pip install torch==2.6.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/xpu --no-cache-dir
RUN pip install intel-extension-for-pytorch==2.6.10+xpu oneccl_bind_pt==2.6.0+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/ --no-cache-dir

ENV CCL_ROOT=/opt/intel/oneapi/ccl/latest
ENV I_MPI_ROOT=/opt/intel/oneapi/mpi/latest
ENV FI_PROVIDER_PATH=/opt/intel/oneapi/mpi/latest/opt/mpi/libfabric/lib/prov:/usr/lib/x86_64-linux-gnu/libfabric
Expand All @@ -132,7 +132,7 @@ COPY backends backends
COPY backends/python/server/text_embeddings_server/models/__init__.py backends/python/server/text_embeddings_server/models/__init__.py
COPY backends/python/server/pyproject.toml backends/python/server/pyproject.toml
RUN cd backends/python/server && \
make install
make install-xpu

FROM ${PLATFORM} AS grpc

Expand All @@ -144,6 +144,8 @@ CMD ["--json-output"]
FROM ${PLATFORM}

COPY --from=http-builder /usr/src/target/release/text-embeddings-router /usr/local/bin/text-embeddings-router
ENV VIRTUAL_ENV=/usr/src/backends/python/server/.venv
ENV PATH=$VIRTUAL_ENV/bin/:$PATH

ENTRYPOINT ["text-embeddings-router"]
CMD ["--json-output"]
22 changes: 17 additions & 5 deletions backends/python/server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,24 @@ gen-server:
touch text_embeddings_server/pb/__init__.py

install: gen-server
pip install pip poetry --upgrade
poetry install
pip install pip uv --upgrade
uv sync

install-intel: gen-server
pip install pip poetry --upgrade
poetry install --without cuda
install-cpu: gen-server
pip install pip uv --upgrade
uv sync --extra cpu

install-xpu: gen-server
pip install pip uv --upgrade
uv sync --extra xpu

install-gpu: gen-server
pip install pip uv --upgrade
uv sync --extra gpu

install-hpu: gen-server
pip install pip uv --upgrade
uv sync --extra hpu --inexact

run-dev:
python text_embeddings_server/cli.py serve BAAI/bge-small-en
Expand Down
Loading
Loading