khoj-ai / khoj

Your AI second brain. Get answers to your questions, whether they be online or in your own notes. Use online AI models (e.g gpt4) or private, local LLMs (e.g llama3). Self-host locally or use our cloud instance. Access from Obsidian, Emacs, Desktop app, Web or Whatsapp.
https://khoj.dev
GNU Affero General Public License v3.0
12.63k stars 640 forks source link

[FIX] LibGL Import Error on docker-compose up #848

Closed tezansahu closed 1 month ago

tezansahu commented 2 months ago

Describe the bug

Tried to follow the steps mentioned in 1A. Install Method 1: Docker. Copied the docker-compose.yml file from GitHub & updated the KHOJ_ADMIN_EMAIL & KHOJ_ADMIN_PASSWORD, as mentioned & proceeded to perform docker-compose up.

On performing docker-compose up, the database container (khoj-database-1) starts & keeps running, however the server container (khoj-server-1) tries to starts & exits with the following error: ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Here is the stack trace:

server-1    | Traceback (most recent call last):
server-1    |   File "/app/src/khoj/main.py", line 93, in <module>
server-1    |     from khoj.configure import configure_routes, initialize_server, configure_middleware
server-1    |   File "/app/src/khoj/configure.py", line 40, in <module>
server-1    |     from khoj.routers.indexer import configure_content, configure_search
server-1    |   File "/app/src/khoj/routers/indexer.py", line 12, in <module>
server-1    |     from khoj.processor.content.images.image_to_entries import ImageToEntries
server-1    |   File "/app/src/khoj/processor/content/images/image_to_entries.py", line 7, in <module>
server-1    |     from rapidocr_onnxruntime import RapidOCR
server-1    |   File "/usr/local/lib/python3.10/dist-packages/rapidocr_onnxruntime/__init__.py", line 4, in <module>
server-1    |     from .main import RapidOCR
server-1    |   File "/usr/local/lib/python3.10/dist-packages/rapidocr_onnxruntime/main.py", line 8, in <module>
server-1    |     import cv2
server-1    |   File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 181, in <module>
server-1    |     bootstrap()
server-1    |   File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 153, in bootstrap
server-1    |     native_module = importlib.import_module("cv2")
server-1    |   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
server-1    |     return _bootstrap._gcd_import(name[level:], package, level)
server-1    | ImportError: libGL.so.1: cannot open shared object file: No such file or directory
server-1 exited with code 1

I do see this warning on entering docker-compose up though:

time="2024-07-12T07:07:06+05:30" level=warning msg="C:\\Users\\tezan\\source\\khoj\\docker-compose.yml: `version` is obsolete"`

To Reproduce

Follow the exact steps mentioned in "1A. Install Method 1: Docker" of the Khoj AI docs

Screenshots

image

image

Platform

If self-hosted

Additional context

Add any other context about the problem here.

AnkushMalaker commented 2 months ago

Warning is irrelevant.
Seems related to this. Based on comment under linked answer I can assume cv2 requires this. Based on error message I'm assuming rapidOCR needed it.
Putting specified RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y under the

# Install RapidOCR dependencies
RUN apt -y install libgl1 libgl1-mesa-glx libglib2.0-0

part and rebuilding image seems to fix the issue. To rebuild, you'll need to comment this line out and uncomment these two.

Cheers.

debanjum commented 2 months ago

Hey @tezansahu thanks for raising an issue for this. It was fixed in this PR. You can build from source, like @AnkushMalaker mentioned or update the docker-compose.yml to use the pre tagged docker images.

The latest tagged docker images tracks the latest Khoj release. The fix was done after the previous release. We should have a new release out in a few days as well, in case you want to wait.

debanjum commented 1 month ago

Closing this issue as it should be fixed now in the latest release (0.17.0)