ryan-serpico
ryan-serpico

Reputation: 31

docker container crashes with exited with code 139 on Sonoma when embedding

Ever since upgrading my main machine to macOS Sonoma, I haven't been able to generate any embeddings using Chroma in my Docker container. Every time I run docker-compose up --index embedding-test with the basic code below, I receive exited with code 139.

What I don't understand is that I can run this same Docker container on another Mac running Monterey and on an EC2 server without any issue. I can get the same script below running on my main machine if I run it outside of a Docker container and in a simple venv.

I've never submitted an issue on Github, so apologies in advance if this posting is misplaced. I'm also attaching my Dockerfile. If I can supply any other information that would lead to any assistance, let me know. I would appreciate any help on this issue.

embedding_test.py


import chromadb
from chromadb.utils import embedding_functions

# Let's define the embedding function
embedding = embedding_functions.SentenceTransformerEmbeddingFunction(
    model_name="intfloat/e5-base-v2",
)

persist_directory = "/code/scripts/testDB"

client = chromadb.PersistentClient(path=persist_directory)

client.delete_collection(name="Students")

collection = client.create_collection(name="Students")

student_info = """
Alexandra Thompson, a 19-year-old computer science sophomore with a 3.7 GPA,
is a member of the programming and chess clubs who enjoys pizza, swimming, and hiking
in her free time in hopes of working at a tech company after graduating from the University of Washington.
"""

club_info = """
The university chess club provides an outlet for students to come together and enjoy playing
the classic strategy game of chess. Members of all skill levels are welcome, from beginners learning
the rules to experienced tournament players. The club typically meets a few times per week to play casual games,
participate in tournaments, analyze famous chess matches, and improve members' skills.
"""

university_info = """
The University of Washington, founded in 1861 in Seattle, is a public research university
with over 45,000 students across three campuses in Seattle, Tacoma, and Bothell.
As the flagship institution of the six public universities in Washington state,
UW encompasses over 500 buildings and 20 million square feet of space,
including one of the largest library systems in the world.
"""

embeddings = embedding([student_info, club_info, university_info])

collection.add(
    documents=embeddings,
    metadatas=[
        {"source": "student info"},
        {"source": "club info"},
        {"source": "university info"},
    ],
    ids=["id1", "id2", "id3"],
)

results = collection.query(query_texts=["What is the student name?"], n_results=2)

print(results)

Dockerfile

FROM python:3.11.4-slim-bookworm
ADD requirements.txt /code/requirements.txt
WORKDIR /code

RUN apt-get update
RUN apt-get install build-essential -y
RUN apt-get install -y gdal-bin libgdal-dev
RUN pip install --upgrade pip
RUN pip install -r "requirements.txt"
RUN python -m spacy download en_core_web_sm

# Add the scripts from the local 'scripts` folder
ADD scripts/embedding_test.py /code/scripts/

WORKDIR /code/scripts

requirements.txt

beautifulsoup4==4.12.2
chromadb==0.4.13
geopandas==0.14.0
gspread==5.11.3
gspread_dataframe==3.3.1
langchain==0.0.306
openai==0.27.9
pandas==2.0.3
python-dotenv==1.0.0
pytz==2023.3
Requests==2.31.0
slack_bolt==1.18.0
slack_sdk==3.21.3
spacy==3.6.1
tenacity==8.2.3
tiktoken==0.4.0
sentence_transformers==2.2.2
lark==1.1.7
Versions

Versions

Chroma v0.4.13, macOS 14.0 Sonoma, Docker v4.24.0, python:3.11.4-slim-bookworm image

Log output

docker-compose up embedding-test
[+] Building 0.0s (0/0)                                                                                                                                                                                                                                                                              docker:desktop-linux
[+] Running 1/0
 ✔ Container chowbot-embedding-test-1  Created                                                                                                                                                                                                                                                                       0.0s 
Attaching to chowbot-embedding-test-1
chowbot-embedding-test-1 exited with code 139

I have pruned system, container and image. I have uninstalled and reinstalled Docker. I have tried running the Docker container on other machines with success. I have been able to run this code outside of a Docker container and within a venv with success.

No matter what I do with this Docker container on macOS Sonoma, I get error 139 instead of my embeddings being created.

Upvotes: 2

Views: 759

Answers (1)

narnia
narnia

Reputation: 11

Reverting torch fixed this

torch==2.0.1

Reference Issue here

Torch supposedly fixed it here

Upvotes: 1

Related Questions