Skip to content

Commit

Permalink
update: docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfeil committed Nov 14, 2024
1 parent f0c532d commit ba3ceba
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 18 deletions.
4 changes: 4 additions & 0 deletions libs/infinity_emb/Docker.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ amd:
RUN ./requirements_install_from_poetry.sh --no-root --without lint,test "https://download.pytorch.org/whl/rocm6.2"
poetry_extras: "all onnxruntime-gpu"
python_version: python3.10
extra_env_variables: |
# Sets default to onnx
RUN conda init --reverse --all
RUN rm -rf /opt/conda && rm -rf /var/lib/jenkins
trt:
base_image: nvidia/cuda:12.3.2-cudnn9-devel-ubuntu22.04
Expand Down
6 changes: 4 additions & 2 deletions libs/infinity_emb/Dockerfile.amd_auto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ ENV PYTHONUNBUFFERED=1 \
EXTRAS="all onnxruntime-gpu" \
PYTHON="python3.10"
RUN apt-get update && apt-get install --no-install-recommends -y build-essential python3-dev libsndfile1 $PYTHON-venv $PYTHON curl
# Sets default to onnx
RUN conda init --reverse --all
RUN rm -rf /opt/conda && rm -rf /var/lib/jenkins

WORKDIR /app

FROM base as builder
Expand Down Expand Up @@ -90,8 +94,6 @@ COPY --from=builder /app /app
COPY --from=testing /app/test_results.txt /app/test_results.txt
ENV HF_HOME=/app/.cache/huggingface
ENV PATH=/app/.venv/bin:$PATH
# do nothing
#

# Use a multi-stage build -> production version, with download
# docker buildx build --target=production-with-download \
Expand Down
7 changes: 3 additions & 4 deletions libs/infinity_emb/Dockerfile.cpu_auto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ ENV PYTHONUNBUFFERED=1 \
EXTRAS="all openvino" \
PYTHON="python3.11"
RUN apt-get update && apt-get install --no-install-recommends -y build-essential python3-dev libsndfile1 $PYTHON-venv $PYTHON curl
# Sets default to onnx
ENV INFINITY_ENGINE="optimum"

WORKDIR /app

FROM base as builder
Expand Down Expand Up @@ -90,10 +93,6 @@ COPY --from=builder /app /app
COPY --from=testing /app/test_results.txt /app/test_results.txt
ENV HF_HOME=/app/.cache/huggingface
ENV PATH=/app/.venv/bin:$PATH
# do nothing
# Sets default to onnx
ENV INFINITY_ENGINE="optimum"


# Use a multi-stage build -> production version, with download
# docker buildx build --target=production-with-download \
Expand Down
3 changes: 1 addition & 2 deletions libs/infinity_emb/Dockerfile.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ENV PYTHONUNBUFFERED=1 \
EXTRAS="{{poetry_extras | default('all')}}" \
PYTHON="{{python_version | default('python3.11')}}"
RUN apt-get update && apt-get install --no-install-recommends -y build-essential python3-dev libsndfile1 $PYTHON-venv $PYTHON curl
{{extra_env_variables | default('')}}
WORKDIR /app

FROM base as builder
Expand Down Expand Up @@ -81,8 +82,6 @@ COPY --from=builder /app /app
COPY --from=testing /app/test_results.txt /app/test_results.txt
ENV HF_HOME=/app/.cache/huggingface
ENV PATH=/app/.venv/bin:$PATH
# do nothing
{{extra_env_variables | default('#')}}

# Use a multi-stage build -> production version, with download
# docker buildx build --target=production-with-download \
Expand Down
3 changes: 1 addition & 2 deletions libs/infinity_emb/Dockerfile.nvidia_auto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ENV PYTHONUNBUFFERED=1 \
EXTRAS="all" \
PYTHON="python3.11"
RUN apt-get update && apt-get install --no-install-recommends -y build-essential python3-dev libsndfile1 $PYTHON-venv $PYTHON curl

WORKDIR /app

FROM base as builder
Expand Down Expand Up @@ -81,8 +82,6 @@ COPY --from=builder /app /app
COPY --from=testing /app/test_results.txt /app/test_results.txt
ENV HF_HOME=/app/.cache/huggingface
ENV PATH=/app/.venv/bin:$PATH
# do nothing
#

# Use a multi-stage build -> production version, with download
# docker buildx build --target=production-with-download \
Expand Down
9 changes: 4 additions & 5 deletions libs/infinity_emb/Dockerfile.trt_onnx_auto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ ENV PYTHONUNBUFFERED=1 \
EXTRAS="all onnxruntime-gpu" \
PYTHON="python3.10"
RUN apt-get update && apt-get install --no-install-recommends -y build-essential python3-dev libsndfile1 $PYTHON-venv $PYTHON curl
# Set default to tensorrt
ENV LD_LIBRARY_PATH=/app/.venv/lib/${PYTHON}/site-packages/tensorrt:/usr/lib/x86_64-linux-gnu:/app/.venv/lib/${PYTHON}/site-packages/tensorrt_libs:${LD_LIBRARY_PATH}
ENV PATH=/app/.venv/lib/${PYTHON}/site-packages/tensorrt/bin:${PATH}

WORKDIR /app

FROM base as builder
Expand Down Expand Up @@ -85,11 +89,6 @@ COPY --from=builder /app /app
COPY --from=testing /app/test_results.txt /app/test_results.txt
ENV HF_HOME=/app/.cache/huggingface
ENV PATH=/app/.venv/bin:$PATH
# do nothing
# Set default to tensorrt
ENV LD_LIBRARY_PATH=/app/.venv/lib/${PYTHON}/site-packages/tensorrt:/usr/lib/x86_64-linux-gnu:/app/.venv/lib/${PYTHON}/site-packages/tensorrt_libs:${LD_LIBRARY_PATH}
ENV PATH=/app/.venv/lib/${PYTHON}/site-packages/tensorrt/bin:${PATH}


# Use a multi-stage build -> production version, with download
# docker buildx build --target=production-with-download \
Expand Down
15 changes: 14 additions & 1 deletion libs/infinity_emb/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all clean docs_build docs_clean docs_linkcheck api_docs_build api_docs_clean api_docs_linkcheck format lint test tests test_watch template_docker integration_tests docker_tests help extended_tests
.PHONY: all clean docs_build docs_clean docs_linkcheck api_docs_build api_docs_clean api_docs_linkcheck format lint test tests test_watch template_docker integration_tests docker_tests help extended_tests build-all-docker build-amd build-trt

# Default target executed when no arguments are given to make.
all: help
Expand All @@ -11,6 +11,7 @@ precommit : | format spell_fix spell_check lint poetry_check cli_v2_docs templat

# Define a variable for the test file path.
TEST_FILE ?= tests/unit_tests/
VERSION ?= DEV

# Run unit tests and generate a coverage report.
coverage:
Expand Down Expand Up @@ -46,6 +47,18 @@ template_docker:
jinja2 Dockerfile.jinja2 Docker.template.yaml --format=yaml -s nvidia > Dockerfile.nvidia_auto
jinja2 Dockerfile.jinja2 Docker.template.yaml --format=yaml -s trt > Dockerfile.trt_onnx_auto

# Add new targets
build-amd:
docker buildx build -t michaelf34/infinity:$(VERSION)-amd -f Dockerfile.amd_auto --push .

build-trt:
docker buildx build -t michaelf34/infinity:$(VERSION)-trt-onnx -f Dockerfile.trt_onnx_auto --push .

# Combined target to build both
build-all-docker:
docker buildx build -t michaelf34/infinity:$(VERSION)-amd -f Dockerfile.amd_auto --push . & \
docker buildx build -t michaelf34/infinity:$(VERSION)-trt-onnx -f Dockerfile.trt_onnx_auto --push .

poetry_check:
poetry check

Expand Down
9 changes: 7 additions & 2 deletions libs/infinity_emb/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions libs/infinity_emb/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ all=[
tensorrt=["tensorrt"]
onnxruntime-gpu=["onnxruntime-gpu"]

[[tool.poetry.source]]
name = "pypi"
priority = "primary"

[[tool.poetry.source]]
# used for monkey-patching cpu onlu
name = "pytorch_cpu"
Expand Down

0 comments on commit ba3ceba

Please sign in to comment.