Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PERF]: Optimized docker image #1613

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
FROM python:3.10-slim-bookworm as builder

FROM python:3.11-slim-bookworm AS builder
ARG REBUILD_HNSWLIB
RUN apt-get update --fix-missing && apt-get install -y --fix-missing \
build-essential \
gcc \
g++ && \
rm -rf /var/lib/apt/lists/*
g++ \
cmake \
autoconf && \
rm -rf /var/lib/apt/lists/* && \
mkdir /install

RUN mkdir /install
WORKDIR /install

COPY ./requirements.txt requirements.txt

RUN pip install --no-cache-dir --upgrade --prefix="/install" -r requirements.txt
RUN if [ "$REBUILD_HNSWLIB" = "true" ]; then pip install --no-binary :all: --force-reinstall --no-cache-dir --prefix="/install" chroma-hnswlib; fi

FROM python:3.10-slim-bookworm as final

RUN apt-get update --fix-missing && apt-get install -y --fix-missing \
build-essential \
gcc \
g++ && \
rm -rf /var/lib/apt/lists/*
FROM python:3.11-slim-bookworm AS final

RUN mkdir /chroma
WORKDIR /chroma
Expand Down
2 changes: 0 additions & 2 deletions bin/docker_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

echo "Rebuilding hnsw to ensure architecture compatibility"
pip install --force-reinstall --no-cache-dir chroma-hnswlib
export IS_PERSISTENT=1
export CHROMA_SERVER_NOFILE=65535
uvicorn chromadb.app:app --workers 1 --host 0.0.0.0 --port 8000 --proxy-headers --log-config chromadb/log_config.yml --timeout-keep-alive 30
10 changes: 10 additions & 0 deletions examples/advanced/hadrware-optimized-image.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Building Hardware Optimized ChromaDB Image

The default Chroma DB image comes with binary distribution of hnsw lib which is not optimized to take advantage of
certain CPU architectures (Intel-based) with AVX support. This can be improved by building an image with hnsw rebuilt
from source. To do that run:

```bash
docker build -t chroma-test1 --build-arg REBUILD_HNSWLIB=true --no-cache .
```