From c22c4a0f7313bcdfdbed24f3569401207341a9f9 Mon Sep 17 00:00:00 2001 From: Sarah G Date: Tue, 19 Sep 2023 18:15:17 +0200 Subject: [PATCH] Overwrite torch and torchvision versions for prod install --- backend/Dockerfile | 10 +++++----- backend/{requirements/common.txt => requirements.txt} | 5 ++++- backend/requirements/dev.txt | 3 --- backend/requirements/prod.txt | 3 --- 4 files changed, 9 insertions(+), 12 deletions(-) rename backend/{requirements/common.txt => requirements.txt} (55%) delete mode 100644 backend/requirements/dev.txt delete mode 100644 backend/requirements/prod.txt diff --git a/backend/Dockerfile b/backend/Dockerfile index 07b58d52..841f1a94 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -14,10 +14,10 @@ RUN apt update && apt install -y \ && rm -rf /var/lib/apt/lists/* # install python libraries (except torch) -COPY requirements/ requirements/ +COPY requirements.txt . ENV PIP_CERT=$CACERT_LOCATION RUN pip --default-timeout=300 install --upgrade pip \ - && pip --default-timeout=300 install --no-cache-dir -r requirements/common.txt \ + && pip --default-timeout=300 install --no-cache-dir -r requirements.txt \ && rm -r /root/.cache ARG VERSION @@ -31,14 +31,14 @@ RUN mkdir -p src/weights \ # launch website FROM base as dev -RUN pip --default-timeout=300 install --no-cache-dir -r requirements/dev.txt CMD ["uvicorn", "src.main:app", "--reload", "--host", "0.0.0.0", "--port", "5000"] FROM base as test -RUN pip install -r requirements/dev.txt && pip install requests && rm -r /root/.cache +RUN pip install requests && rm -r /root/.cache COPY tests/ tests/ CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "5000"] FROM base as prod -RUN pip install --no-cache-dir -r requirements/prod.txt +RUN pip install --extra-index-url https://download.pytorch.org/whl/cpu \ + torch==1.13.0+cpu torchvision==0.14.0+cpu && rm -r /root/.cache CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "5000"] diff --git a/backend/requirements/common.txt b/backend/requirements.txt similarity index 55% rename from backend/requirements/common.txt rename to backend/requirements.txt index d8d3424b..ed67a7bd 100644 --- a/backend/requirements/common.txt +++ b/backend/requirements.txt @@ -1,3 +1,4 @@ +--extra-index-url https://download.pytorch.org/whl/cpu fastapi==0.68.0 uvicorn==0.14.0 python-multipart>=0.0.5 @@ -6,4 +7,6 @@ pyyaml>=5.4.1 user-agents==2.2.0 ua-parser==0.10.0 python-openstackclient==5.8.0 -python-swiftclient==4.0.0 \ No newline at end of file +python-swiftclient==4.0.0 +torch==1.13.0 +torchvision==0.14.0 \ No newline at end of file diff --git a/backend/requirements/dev.txt b/backend/requirements/dev.txt deleted file mode 100644 index 3ab327fc..00000000 --- a/backend/requirements/dev.txt +++ /dev/null @@ -1,3 +0,0 @@ ---extra-index-url https://download.pytorch.org/whl/cpu -torch==1.13.0 -torchvision==0.14.0 \ No newline at end of file diff --git a/backend/requirements/prod.txt b/backend/requirements/prod.txt deleted file mode 100644 index 8f4ca7ca..00000000 --- a/backend/requirements/prod.txt +++ /dev/null @@ -1,3 +0,0 @@ ---extra-index-url https://download.pytorch.org/whl/cpu -torch==1.13.0+cpu -torchvision==0.14.0+cpu \ No newline at end of file