mirror of
https://github.com/mudler/LocalAI.git
synced 2024-12-18 20:27:57 +00:00
feat(venv): shared env (#3195)
* feat(venv): allow to share veenvs Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(vllm): add back flash-attn Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
11b2adae0c
commit
66cf38b0b3
@ -18,10 +18,23 @@
|
|||||||
# source $(dirname $0)/../common/libbackend.sh
|
# source $(dirname $0)/../common/libbackend.sh
|
||||||
#
|
#
|
||||||
function init() {
|
function init() {
|
||||||
|
# Name of the backend (directory name)
|
||||||
BACKEND_NAME=${PWD##*/}
|
BACKEND_NAME=${PWD##*/}
|
||||||
|
|
||||||
|
# Path where all backends files are
|
||||||
MY_DIR=$(realpath `dirname $0`)
|
MY_DIR=$(realpath `dirname $0`)
|
||||||
|
|
||||||
|
# Build type
|
||||||
BUILD_PROFILE=$(getBuildProfile)
|
BUILD_PROFILE=$(getBuildProfile)
|
||||||
|
|
||||||
|
# Environment directory
|
||||||
|
EDIR=${MY_DIR}
|
||||||
|
|
||||||
|
# Allow to specify a custom env dir for shared environments
|
||||||
|
if [ "x${ENV_DIR}" != "x" ]; then
|
||||||
|
EDIR=${ENV_DIR}
|
||||||
|
fi
|
||||||
|
|
||||||
# If a backend has defined a list of valid build profiles...
|
# If a backend has defined a list of valid build profiles...
|
||||||
if [ ! -z "${LIMIT_TARGETS}" ]; then
|
if [ ! -z "${LIMIT_TARGETS}" ]; then
|
||||||
isValidTarget=$(checkTargets ${LIMIT_TARGETS})
|
isValidTarget=$(checkTargets ${LIMIT_TARGETS})
|
||||||
@ -74,13 +87,14 @@ function getBuildProfile() {
|
|||||||
# This function is idempotent, so you can call it as many times as you want and it will
|
# This function is idempotent, so you can call it as many times as you want and it will
|
||||||
# always result in an activated virtual environment
|
# always result in an activated virtual environment
|
||||||
function ensureVenv() {
|
function ensureVenv() {
|
||||||
if [ ! -d "${MY_DIR}/venv" ]; then
|
if [ ! -d "${EDIR}/venv" ]; then
|
||||||
uv venv ${MY_DIR}/venv
|
uv venv ${EDIR}/venv
|
||||||
echo "virtualenv created"
|
echo "virtualenv created"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "x${VIRTUAL_ENV}" != "x${MY_DIR}/venv" ]; then
|
# Source if we are not already in a Virtual env
|
||||||
source ${MY_DIR}/venv/bin/activate
|
if [ "x${VIRTUAL_ENV}" != "x${EDIR}/venv" ]; then
|
||||||
|
source ${EDIR}/venv/bin/activate
|
||||||
echo "virtualenv activated"
|
echo "virtualenv activated"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -113,21 +127,25 @@ function installRequirements() {
|
|||||||
|
|
||||||
# These are the requirements files we will attempt to install, in order
|
# These are the requirements files we will attempt to install, in order
|
||||||
declare -a requirementFiles=(
|
declare -a requirementFiles=(
|
||||||
"${MY_DIR}/requirements-install.txt"
|
"${EDIR}/requirements-install.txt"
|
||||||
"${MY_DIR}/requirements.txt"
|
"${EDIR}/requirements.txt"
|
||||||
"${MY_DIR}/requirements-${BUILD_TYPE}.txt"
|
"${EDIR}/requirements-${BUILD_TYPE}.txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ "x${BUILD_TYPE}" != "x${BUILD_PROFILE}" ]; then
|
if [ "x${BUILD_TYPE}" != "x${BUILD_PROFILE}" ]; then
|
||||||
requirementFiles+=("${MY_DIR}/requirements-${BUILD_PROFILE}.txt")
|
requirementFiles+=("${EDIR}/requirements-${BUILD_PROFILE}.txt")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if BUILD_TYPE is empty, we are a CPU build, so we should try to install the CPU requirements
|
# if BUILD_TYPE is empty, we are a CPU build, so we should try to install the CPU requirements
|
||||||
if [ "x${BUILD_TYPE}" == "x" ]; then
|
if [ "x${BUILD_TYPE}" == "x" ]; then
|
||||||
requirementFiles+=("${MY_DIR}/requirements-cpu.txt")
|
requirementFiles+=("${EDIR}/requirements-cpu.txt")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
requirementFiles+=("${MY_DIR}/requirements-after.txt")
|
requirementFiles+=("${EDIR}/requirements-after.txt")
|
||||||
|
|
||||||
|
if [ "x${BUILD_TYPE}" != "x${BUILD_PROFILE}" ]; then
|
||||||
|
requirementFiles+=("${EDIR}/requirements-${BUILD_PROFILE}-after.txt")
|
||||||
|
fi
|
||||||
|
|
||||||
for reqFile in ${requirementFiles[@]}; do
|
for reqFile in ${requirementFiles[@]}; do
|
||||||
if [ -f ${reqFile} ]; then
|
if [ -f ${reqFile} ]; then
|
||||||
|
1
backend/python/vllm/requirements-cublas11-after.txt
Normal file
1
backend/python/vllm/requirements-cublas11-after.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
flash-attn
|
1
backend/python/vllm/requirements-cublas12-after.txt
Normal file
1
backend/python/vllm/requirements-cublas12-after.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
flash-attn
|
Loading…
Reference in New Issue
Block a user