From 9a632df9d6e587b60f25dd4526821e3dfeb76662 Mon Sep 17 00:00:00 2001 From: "chen, suyue" Date: Mon, 12 Aug 2024 14:21:39 +0800 Subject: [PATCH] Optional container build instructions (#457) Signed-off-by: chensuyue --- comps/agent/langchain/docker/Dockerfile | 8 ++++++-- comps/asr/Dockerfile | 7 ++++++- comps/asr/whisper/Dockerfile | 6 ++++++ comps/tts/Dockerfile | 7 ++++++- comps/tts/speecht5/Dockerfile | 7 ++++++- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/comps/agent/langchain/docker/Dockerfile b/comps/agent/langchain/docker/Dockerfile index 62b4ea2bc..9a966b952 100644 --- a/comps/agent/langchain/docker/Dockerfile +++ b/comps/agent/langchain/docker/Dockerfile @@ -4,6 +4,7 @@ FROM python:3.11-slim ENV LANG=C.UTF-8 +ARG ARCH=cpu RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ @@ -19,8 +20,11 @@ USER user COPY comps /home/user/comps RUN pip install --no-cache-dir --upgrade pip setuptools && \ - if [ ${ARCH} = "cpu" ]; then pip install torch --index-url https://download.pytorch.org/whl/cpu; fi && \ - pip install --no-cache-dir -r /home/user/comps/agent/langchain/requirements.txt + if [ ${ARCH} = "cpu" ]; then \ + pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu -r /home/user/comps/agent/langchain/requirements.txt; \ + else \ + pip install --no-cache-dir -r /home/user/comps/agent/langchain/requirements.txt; \ + fi ENV PYTHONPATH=$PYTHONPATH:/home/user diff --git a/comps/asr/Dockerfile b/comps/asr/Dockerfile index 2e8731e85..3a4425437 100644 --- a/comps/asr/Dockerfile +++ b/comps/asr/Dockerfile @@ -9,11 +9,16 @@ RUN useradd -m -s /bin/bash user && \ USER user ENV LANG=C.UTF-8 +ARG ARCH=cpu COPY comps /home/user/comps RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r /home/user/comps/asr/requirements.txt + if [ "${ARCH}" = "cpu" ]; then \ + pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu -r /home/user/comps/asr/requirements.txt ; \ + else \ + pip install --no-cache-dir -r /home/user/comps/asr/requirements.txt ; \ + fi ENV PYTHONPATH=$PYTHONPATH:/home/user diff --git a/comps/asr/whisper/Dockerfile b/comps/asr/whisper/Dockerfile index f0e09e5fb..86737e7d8 100644 --- a/comps/asr/whisper/Dockerfile +++ b/comps/asr/whisper/Dockerfile @@ -10,6 +10,7 @@ RUN useradd -m -s /bin/bash user && \ # Set environment variables ENV LANG=en_US.UTF-8 +ARG ARCH=cpu # Install system dependencies RUN apt-get update \ @@ -21,6 +22,11 @@ USER user RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r /home/user/comps/asr/requirements.txt && \ + if [ "${ARCH}" = "cpu" ]; then \ + pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu -r /home/user/comps/asr/requirements.txt ; \ + else \ + pip install --no-cache-dir -r /home/user/comps/asr/requirements.txt ; \ + fi pip list ENV PYTHONPATH=$PYTHONPATH:/home/user diff --git a/comps/tts/Dockerfile b/comps/tts/Dockerfile index ae00a24e3..69d3c8a77 100644 --- a/comps/tts/Dockerfile +++ b/comps/tts/Dockerfile @@ -7,11 +7,16 @@ RUN useradd -m -s /bin/bash user && \ chown -R user /home/user/ USER user ENV LANG=C.UTF-8 +ARG ARCH=cpu COPY comps /home/user/comps RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r /home/user/comps/tts/requirements.txt + if [ "${ARCH}" = "cpu" ]; then \ + pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu -r /home/user/comps/tts/requirements.txt ; \ + else \ + pip install --no-cache-dir -r /home/user/comps/tts/requirements.txt ; \ + fi ENV PYTHONPATH=$PYTHONPATH:/home/user diff --git a/comps/tts/speecht5/Dockerfile b/comps/tts/speecht5/Dockerfile index 5ddd43e2c..fd34aa0df 100644 --- a/comps/tts/speecht5/Dockerfile +++ b/comps/tts/speecht5/Dockerfile @@ -9,6 +9,7 @@ RUN useradd -m -s /bin/bash user && \ # Set environment variables ENV LANG=en_US.UTF-8 ENV PYTHONPATH=/home/user +ARG ARCH=cpu # Install system dependencies RUN apt-get update \ @@ -20,7 +21,11 @@ COPY --chown=user:user comps /home/user/comps USER user RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r /home/user/comps/tts/requirements.txt + if [ "${ARCH}" = "cpu" ]; then \ + pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu -r /home/user/comps/tts/requirements.txt ; \ + else \ + pip install --no-cache-dir -r /home/user/comps/tts/requirements.txt ; \ + fi ENV PYTHONPATH=$PYTHONPATH:/home/user