LoginSignup
0
0

Render.comにchromaDBと使ったプロダクトをデプロイするときにError: Your system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0と出る

Last updated at Posted at 2024-06-28

背景

langchainとFastAPIを使ったアプリを作成し、Dockerでデプロイしようとしたときにエラーが出た。

エラー本文

Render.comに作ったアプリをデプロイするとこんなエラーが出た。

Error: Your system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0

どうやらChromadbにはsqlite3のバージョンが3.35.0以上のものが必要らしい。
調べてみるとRenderで使えるsqliteのバージョンは3.27.2らしい。
こりゃ古くてエラー出るわけだ。

解決策

sqliteのバージョンが古いならchromadbのバージョンを下げればいいじゃない。
ということで、sqliteのバージョンが3.27.2で使えるchromadbのバージョンを探す。
と、こんな質問板が海外にあった。
https://community.render.com/t/your-system-has-an-unsupported-version-of-sqlite3-chroma-requires-sqlite3-3-35-0/13807/4
chromadbは0.3.29のものをインストールする。

$ pip install "chromadb==0.3.29"

pydanticのバージョンも下げないといけないのでfastAPIもバージョンを下げる。

$ pip install "fastapi==0.85.1"

これでデプロイしようとしたら次はこんなエラーが出てきた。
くそ長いので重要そうなところだけ書いておく。

#10 17.30 Building wheels for collected packages: hnswlib, PyPika
#10 17.30   Building wheel for hnswlib (pyproject.toml): started
#10 17.62   Building wheel for hnswlib (pyproject.toml): finished with status 'error'
#10 17.63   error: subprocess-exited-with-error
#10 17.63   
#10 17.63   × Building wheel for hnswlib (pyproject.toml) did not run successfully.
#10 17.63   │ exit code: 1
#10 17.63   ╰─> [60 lines of output]
#10 17.63       running bdist_wheel
#10 17.63       running build
#10 17.63       running build_ext
#10 17.63       creating tmp
#10 17.63       gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.11 -c /tmp/tmpl3bnonxs.cpp -o tmp/tmpl3bnonxs.o -std=c++14
・
・
(省略)
・
・
#10 17.63       RuntimeError: Unsupported compiler -- at least C++11 support is needed!
#10 17.63       [end of output]
#10 17.63   
#10 17.63   note: This error originates from a subprocess, and is likely not a problem with pip.
#10 17.63   ERROR: Failed building wheel for hnswlib
#10 17.63   Building wheel for PyPika (pyproject.toml): started
#10 17.80   Building wheel for PyPika (pyproject.toml): finished with status 'done'

どうもchromadbに使うであろうhnswlibのビルドにC++11以上をサポートするgccが必要らしい。
今回筆者はdockerを使っていたのでdockerfileに追記する

# Pythonのベースイメージを作成
FROM python:3.11.3-slim

# 必要なパッケージとGCCをインストール
RUN apt-get update && \
    apt-get install -y --no-install-recommends gcc g++ && \
    rm -rf /var/lib/apt/lists/*

# 作業ディレクトリを指定
WORKDIR /app

# 依存関係ファイルをコピー
COPY requirements.txt .

# 依存関係をインストール
RUN pip install --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# アプリケーションファイルのコピー
COPY . .

# Uvicornを使用してアプリケーションを実行
CMD sh -c "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8080}"

ここまでやったところで筆者は正常にデプロイできた
やったね

余談

もしかしたらDockerとかのコンテナをうまく使えばライブラリのバージョンを下げたりとかいうめんどくさいことなんかしなくていいのかもしれない。
https://community.render.com/t/any-chance-of-choosing-or-upgrading-the-sqlite3-version/17282

この記事書いてるときに
「gccインストールできるならsqliteも新しいバージョンインストールするようにdockerfileを書き換えればよかったんじゃないか」
なんて思ったのは秘密の話。
筆者はDocker触って3日のペーペーなのでよくわかりませんでした。
もしわかる最強のつよつよエンジニアの方いらっしゃったら連絡ください泣いて喜びます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0