Move torch installation method into the pyproject.toml file

This commit is contained in:
Ahmet Öner
2023-02-04 22:54:29 +01:00
parent a540e8d718
commit 3a9a477c9a
5 changed files with 6 additions and 10 deletions

View File

@@ -12,10 +12,6 @@ RUN python3 -m venv $POETRY_VENV \
&& $POETRY_VENV/bin/pip install -U pip setuptools \
&& $POETRY_VENV/bin/pip install poetry
ARG TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then $POETRY_VENV/bin/pip install torch==1.13.0 -f https://download.pytorch.org/whl/cpu; fi;
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then $POETRY_VENV/bin/pip install torch==1.13.0; fi;
ENV PATH="${PATH}:${POETRY_VENV}/bin"
WORKDIR /app

View File

@@ -18,8 +18,7 @@ RUN ln -s -f /usr/bin/python${PYTHON_VERSION} /usr/bin/python3 && \
RUN python3 -m venv $POETRY_VENV \
&& $POETRY_VENV/bin/pip install -U pip setuptools \
&& $POETRY_VENV/bin/pip install poetry \
&& $POETRY_VENV/bin/pip install torch==1.13.0+cu117 -f https://download.pytorch.org/whl/torch
&& $POETRY_VENV/bin/pip install poetry
ENV PATH="${PATH}:${POETRY_VENV}/bin"
@@ -30,4 +29,6 @@ COPY . /app
RUN poetry config virtualenvs.in-project true
RUN poetry install
RUN $POETRY_VENV/bin/pip install torch==1.13.0+cu117 -f https://download.pytorch.org/whl/torch
ENTRYPOINT ["gunicorn", "--bind", "0.0.0.0:9000", "--workers", "1", "--timeout", "0", "app.webservice:app", "-k", "uvicorn.workers.UvicornWorker"]

View File

@@ -49,9 +49,7 @@ pip3 install poetry
Install torch with following command:
```sh
# for cpu:
pip3 install torch==1.13.0+cpu -f https://download.pytorch.org/whl/torch
# for gpu:
# just for GPU:
pip3 install torch==1.13.0+cu117 -f https://download.pytorch.org/whl/torch
```

2
poetry.lock generated
View File

@@ -1363,4 +1363,4 @@ test = ["pytest (>=3.0.0)"]
[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "ea97bcbba17ee719368062f34d112dff3d48641e554c1fdc6dce33ea57eb6bcd"
content-hash = "4377fd9792676d055d432d875cda432368cdd13435f5424e6d5bcb5a4272abde"

View File

@@ -23,6 +23,7 @@ python-multipart = "^0.0.5"
ffmpeg-python = "^0.2.0"
fastapi = "^0.85.0"
fastapi-offline-swagger-ui = {git = "https://github.com/ahmetoner/fastapi-offline-swagger-ui"}
torch="^1.13.0"
[tool.poetry.dev-dependencies]
pytest = "^6.2.5"