mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-20 10:35:01 +00:00
feat: migrate python backends from conda to uv (#2215)
* feat: migrate diffusers backend from conda to uv - replace conda with UV for diffusers install (prototype for all extras backends) - add ability to build docker with one/some/all extras backends instead of all or nothing Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: migrate autogtpq bark coqui from conda to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: convert exllama over to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: migrate exllama2 to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: migrate mamba to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: migrate parler to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: migrate petals to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: fix tests Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: migrate rerankers to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: migrate sentencetransformers to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: install uv for tests-linux Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: make sure file exists before installing on intel images Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: migrate transformers backend to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: migrate transformers-musicgen to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: migrate vall-e-x to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: migrate vllm to uv Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: add uv install to the rest of test-extra.yml Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: adjust file perms on all install/run/test scripts Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: add missing acclerate dependencies Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: add some more missing dependencies to python backends Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: parler tests venv py dir fix Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: correct filename for transformers-musicgen tests Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: adjust the pwd for valle tests Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: cleanup and optimization work for uv migration Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: add setuptools to requirements-install for mamba Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: more size optimization work Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * feat: make installs and tests more consistent, cleanup some deps Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: cleanup Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: mamba backend is cublas only Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> * fix: uncomment lines in makefile Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com> --------- Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com>
This commit is contained in:
parent
e6768097f4
commit
28a421cb1d
101 changed files with 988 additions and 740 deletions
|
@ -1,7 +1,6 @@
|
|||
.PHONY: rerankers
|
||||
rerankers: protogen
|
||||
$(MAKE) -C ../common-env/transformers
|
||||
|
||||
bash install.sh
|
||||
|
||||
.PHONY: run
|
||||
run: protogen
|
||||
|
@ -24,4 +23,8 @@ protogen-clean:
|
|||
$(RM) backend_pb2_grpc.py backend_pb2.py
|
||||
|
||||
backend_pb2_grpc.py backend_pb2.py:
|
||||
python3 -m grpc_tools.protoc -I../.. --python_out=. --grpc_python_out=. backend.proto
|
||||
python3 -m grpc_tools.protoc -I../.. --python_out=. --grpc_python_out=. backend.proto
|
||||
|
||||
.PHONY: clean
|
||||
clean: protogen-clean
|
||||
rm -rf venv
|
34
backend/python/rerankers/install.sh
Executable file
34
backend/python/rerankers/install.sh
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
BUILD_ISOLATION_FLAG=""
|
||||
|
||||
MY_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
||||
|
||||
uv venv ${MY_DIR}/venv
|
||||
source ${MY_DIR}/venv/bin/activate
|
||||
|
||||
if [ -f "requirements-install.txt" ]; then
|
||||
# If we have a requirements-install.txt, it means that a package does not properly declare it's build time
|
||||
# dependencies per PEP-517, so we have to set up the proper build environment ourselves, and then install
|
||||
# the package without build isolation
|
||||
BUILD_ISOLATION_FLAG="--no-build-isolation"
|
||||
uv pip install --requirement ${MY_DIR}/requirements-install.txt
|
||||
fi
|
||||
uv pip install ${BUILD_ISOLATION_FLAG} --requirement ${MY_DIR}/requirements.txt
|
||||
|
||||
if [ -f "requirements-${BUILD_TYPE}.txt" ]; then
|
||||
uv pip install ${BUILD_ISOLATION_FLAG} --requirement ${MY_DIR}/requirements-${BUILD_TYPE}.txt
|
||||
fi
|
||||
|
||||
if [ -d "/opt/intel" ]; then
|
||||
# Intel GPU: If the directory exists, we assume we are using the Intel image
|
||||
# https://github.com/intel/intel-extension-for-pytorch/issues/538
|
||||
if [ -f "requirements-intel.txt" ]; then
|
||||
uv pip install ${BUILD_ISOLATION_FLAG} --index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/ --requirement ${MY_DIR}/requirements-intel.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$PIP_CACHE_PURGE" = true ] ; then
|
||||
pip cache purge
|
||||
fi
|
6
backend/python/rerankers/requirements.txt
Normal file
6
backend/python/rerankers/requirements.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
accelerate
|
||||
rerankers[transformers]
|
||||
grpcio==1.63.0
|
||||
protobuf
|
||||
certifi
|
||||
transformers
|
|
@ -1,14 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
##
|
||||
## A bash script wrapper that runs the reranker server with conda
|
||||
## A bash script wrapper that runs the GRPC backend
|
||||
|
||||
export PATH=$PATH:/opt/conda/bin
|
||||
MY_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
||||
|
||||
# Activate conda environment
|
||||
source activate transformers
|
||||
source $MY_DIR/venv/bin/activate
|
||||
|
||||
# get the directory where the bash script is located
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
python $DIR/reranker.py $@
|
||||
python $MY_DIR/reranker.py $@
|
|
@ -1,11 +1,16 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## A bash script wrapper that runs the reranker server with conda
|
||||
## A bash script wrapper that runs python unittests
|
||||
|
||||
# Activate conda environment
|
||||
source activate transformers
|
||||
MY_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
||||
|
||||
# get the directory where the bash script is located
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
source $MY_DIR/venv/bin/activate
|
||||
|
||||
python -m unittest $DIR/test_reranker.py
|
||||
if [ -f "${MY_DIR}/test.py" ]; then
|
||||
pushd ${MY_DIR}
|
||||
python -m unittest test.py
|
||||
popd
|
||||
else
|
||||
echo "ERROR: No tests defined for backend!"
|
||||
exit 1
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue