@@ -30,10 +30,13 @@ RUN apt-get update && \
3030# Instalar ninja-build y cmake
3131RUN apt-get install -y ninja-build cmake
3232
33- # Configurar variables de entorno para compilar con BLAS y SIMD
34- ENV CFLAGS="-mfma -mavx2" \
35- CXXFLAGS="-mfma -mavx2" \
36- CMAKE_ARGS="-DGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS"
33+ # Configurar variables de entorno para compilar con BLAS y SIMD condicionalmente
34+ ARG ENABLE_OPTIMIZATIONS=true
35+ RUN if [ "${ENABLE_OPTIMIZATIONS}" = "true" ]; then \
36+ export CFLAGS="-mfma -mavx2" ; \
37+ export CXXFLAGS="-mfma -mavx2" ; \
38+ export CMAKE_ARGS="-DGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" ; \
39+ fi
3740
3841# Actualizar pip, setuptools y wheel antes de instalar dependencias
3942RUN python -m pip install --upgrade pip setuptools wheel
@@ -42,13 +45,12 @@ RUN python -m pip install --upgrade pip setuptools wheel
4245COPY ./requirements .
4346
4447# Update pip
45- # RUN python -m pip install --upgrade pip
48+ RUN python -m pip install --upgrade pip
4649
4750# Create Python Dependency and Sub-Dependency Wheels.
4851RUN pip wheel --wheel-dir /usr/src/app/wheels \
4952 -r ${BUILD_ENVIRONMENT}.txt
5053
51-
5254# Python 'run' stage
5355FROM python AS python-run-stage
5456
@@ -59,6 +61,12 @@ ENV PYTHONUNBUFFERED 1
5961ENV PYTHONDONTWRITEBYTECODE 1
6062ENV BUILD_ENV ${BUILD_ENVIRONMENT}
6163
64+ # Disable AVX support for llama-cpp-python if needed
65+ ARG DISABLE_AVX=false
66+
67+ # Set the version of llama-cpp-python
68+ ARG LLAMA_VERSION=0.3.14
69+
6270WORKDIR ${APP_HOME}
6371
6472# Install required system dependencies
@@ -75,10 +83,17 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
7583# copy python dependency wheels from python-build-stage
7684COPY --from=python-build-stage /usr/src/app/wheels /wheels/
7785
78- # use wheels to install python dependencies
79- RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
86+ # Use wheels to install python dependencies (excluding llama-cpp-python)
87+ RUN pip install --no-cache-dir --no-index --find-links=/wheels/ $(find /wheels/ -name "*.whl" ! -name "llama_cpp_python*" ) \
8088 && rm -rf /wheels/
8189
90+ # Install llama-cpp-python with specific CMAKE flags for Kubernetes nodes with our without AVX support
91+ RUN if [ "${DISABLE_AVX}" = "true" ]; then \
92+ CMAKE_ARGS='-DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DLLAMA_F16C=OFF -DLLAMA_OPENMP=ON' pip install llama-cpp-python==${LLAMA_VERSION} --force-reinstall --no-cache-dir; \
93+ else \
94+ pip install llama-cpp-python==${LLAMA_VERSION} --force-reinstall --no-cache-dir; \
95+ fi
96+
8297COPY ./compose/production/django/entrypoint /entrypoint
8398RUN sed -i 's/\r $//g' /entrypoint
8499RUN chmod +x /entrypoint
@@ -87,7 +102,6 @@ COPY ./compose/local/django/start /start
87102RUN sed -i 's/\r $//g' /start
88103RUN chmod +x /start
89104
90-
91105COPY ./compose/local/django/celery/worker/start /start-celeryworker
92106RUN sed -i 's/\r $//g' /start-celeryworker
93107RUN chmod +x /start-celeryworker
@@ -100,7 +114,6 @@ COPY ./compose/local/django/celery/flower/start /start-flower
100114RUN sed -i 's/\r $//g' /start-flower
101115RUN chmod +x /start-flower
102116
103-
104117# copy application code to WORKDIR
105118COPY . ${APP_HOME}
106119
0 commit comments