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.64k stars 640 forks source link

error running khoj in raspberry pi #436

Closed fkgruber closed 10 months ago

fkgruber commented 1 year ago

Hi I was able to install it but when I run it I get:

khoj
/home/fred/.local/lib/python3.9/site-packages/huggingface_hub/snapshot_download.py:6: FutureWarning: snapshot_download.py has been made private and will no longer be available from version 0.11. Please use `from huggingface_hub import snapshot_download` to import the only public function in this module. Other members of the file may be changed without a deprecation notice.
  warnings.warn(
Traceback (most recent call last):
  File "/usr/local/bin/khoj", line 8, in <module>
    sys.exit(run())
  File "/home/fred/.local/lib/python3.9/site-packages/src/main.py", line 290, in run
    config_file = args.config_file
AttributeError: 'NoneType' object has no attribute 'config_file'

Also during installation I noticed the following error:

Getting requirements to build wheel ... done Preparing wheel metadata ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python3 /tmp/tmpuxfw55iin_process.py prepare_metadata_for_build_wheel /tmp/tmp2iudrv7m cwd: /tmp/pip-install-ghvdoa6a/pyqt6_cf5cc37a35284d0d912d63aa355831cb Complete output (31 lines): Traceback (most recent call last): File "/tmp/tmpuxfw55iin_process.py", line 126, in prepare_metadata_for_build_wheel hook = backend.prepare_metadata_for_build_wheel AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/tmpuxfw55i__in_process.py", line 280, in <module>
    main()
  File "/tmp/tmpuxfw55i__in_process.py", line 263, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/tmp/tmpuxfw55i__in_process.py", line 130, in prepare_metadata_for_build_wheel
    return _get_wheel_metadata_from_wheel(backend, metadata_directory,
  File "/tmp/tmpuxfw55i__in_process.py", line 159, in _get_wheel_metadata_from_wheel
    whl_basename = backend.build_wheel(metadata_directory, config_settings)
  File "/tmp/pip-build-env-x109tjpj/overlay/lib/python3.9/site-packages/sipbuild/api.py", line 46, in build_wheel
    project = AbstractProject.bootstrap('wheel',
  File "/tmp/pip-build-env-x109tjpj/overlay/lib/python3.9/site-packages/sipbuild/abstract_project.py", line 87, in bootstrap
    project.setup(pyproject, tool, tool_description)
  File "/tmp/pip-build-env-x109tjpj/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 586, in setup
    self.apply_user_defaults(tool)
  File "project.py", line 67, in apply_user_defaults
    super().apply_user_defaults(tool)
  File "/tmp/pip-build-env-x109tjpj/overlay/lib/python3.9/site-packages/pyqtbuild/project.py", line 70, in apply_user_defaults
    super().apply_user_defaults(tool)
  File "/tmp/pip-build-env-x109tjpj/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 237, in apply_user_defaults
    self.builder.apply_user_defaults(tool)
  File "/tmp/pip-build-env-x109tjpj/overlay/lib/python3.9/site-packages/pyqtbuild/builder.py", line 69, in apply_user_defaults
    raise PyProjectOptionException('qmake',
sipbuild.pyproject.PyProjectOptionException
----------------------------------------
sabaimran commented 1 year ago

Hey @fkgruber , were you able to install the package despite the above errors? I wonder how it let you proceed if there was an issue installing the dependencies.

It looks like you're trying to run an older version of Khoj. I'm guessing this is because pip tried installing older versions until it found one that was compatible. Are you able to run khoj --version, or see what version of Khoj ends up being installed in the logs?

From the logs, it looks like this could be an issue with pyside and glibc. Here's a relevant SO post.

Here's what we can try:

  1. Run ldd --version. You have to be on version 2.35 or greater.
  2. Run pip install --upgrade pip and try re-installing
fkgruber commented 1 year ago

version didn't work

khoj --version /home/fred/.local/lib/python3.9/site-packages/huggingface_hub/snapshot_download.py:6: FutureWarning: snapshot_download.py has been made private and will no longer be available from version 0.11. Please use from huggingface_hub import snapshot_download to import the only public function in this module. Other members of the file may be changed without a deprecation notice. warnings.warn( usage: khoj [-h] [--config-file CONFIG_FILE] [--regenerate] [--verbose] [--host HOST] [--port PORT] [--socket SOCKET] khoj: error: unrecognized arguments: --version

I see my ldd is too old:

fred@raspberrypi3:~$ ldd --version ldd (Debian GLIBC 2.31-13+rpt2+rpi1+deb11u5) 2.31 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Roland McGrath and Ulrich Drepper.

I tried updating pip and reinstalling and got: sudo pip install khoj-assistant

Requirement already satisfied: khoj-assistant in /usr/local/lib/python3.9/dist-packages (0.1.4)

so it does seems to have installed a really old one. I'm trying sudo pip install --upgrade khoj-assistant

Hey @fkgruber , were you able to install the package despite the above errors? I wonder how it let you proceed if there was an issue installing the dependencies.

It looks like you're trying to run an older version of Khoj. I'm guessing this is because pip tried installing older versions until it found one that was compatible. Are you able to run khoj --version, or see what version of Khoj ends up being installed in the logs?

From the logs, it looks like this could be an issue with pyside and glibc. Here's a relevant SO post.

Here's what we can try:

  1. Run ldd --version. You have to be on version 2.35 or greater.
  2. Run pip install --upgrade pip and try re-installing
fkgruber commented 1 year ago

well that did not work. Still ended up with the old version.

I tried sudo pip install --upgrade khoj-assistant==0.10.1 and got

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting khoj-assistant==0.10.1 Using cached https://www.piwheels.org/simple/khoj-assistant/khoj_assistant-0.10.1-py3-none-any.whl (1.2 MB) Collecting defusedxml==0.7.1 Using cached https://www.piwheels.org/simple/defusedxml/defusedxml-0.7.1-py2.py3-none-any.whl (25 kB) Requirement already satisfied: dateparser==1.1.1 in /usr/local/lib/python3.9/dist-packages (from khoj-assistant==0.10.1) (1.1.1) Collecting aiohttp==3.8.4 Using cached aiohttp-3.8.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB) Collecting torch>=2.0.1 Using cached torch-2.0.1-cp39-cp39-manylinux2014_aarch64.whl (74.0 MB) Requirement already satisfied: uvicorn==0.17.6 in /usr/local/lib/python3.9/dist-packages (from khoj-assistant==0.10.1) (0.17.6) Requirement already satisfied: jinja2==3.1.2 in /usr/local/lib/python3.9/dist-packages (from khoj-assistant==0.10.1) (3.1.2) Collecting tenacity>=8.2.2 Using cached https://www.piwheels.org/simple/tenacity/tenacity-8.2.3-py3-none-any.whl (24 kB) ERROR: Could not find a version that satisfies the requirement gpt4all>=1.0.7 (from khoj-assistant) ERROR: No matching distribution found for gpt4all>=1.0.7 fred@raspberrypi3:~$

fkgruber commented 1 year ago

strange I only see old version of gpt4all pip index versions gpt4all WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning. gpt4all (0.1.7) Available versions: 0.1.7, 0.1.6, 0.1.5 INSTALLED: 0.1.7 LATEST: 0.1.7

THis is a well known issue: https://github.com/nomic-ai/gpt4all/issues/748

fkgruber commented 1 year ago

why do I even need gpt4all? Is there a way to install khoj without it? Is this only for the chat functionality?

fkgruber commented 1 year ago

I tried installing khoj using--no-dependencies but then when I run it I get:

OSError: /usr/local/lib/python3.9/dist-packages/gpt4all/llmodel_DO_NOT_MODIFY/build/libllama.so: cannot open shared object file: No such file or directory

debanjum commented 1 year ago

why do I even need gpt4all? Is there a way to install khoj without it? Is this only for the chat functionality?

Yes, gpt4all is only used for the offline chat functionality. We don't currently provide different flavors of the khoj python package unfortunately.

The best you can do right now is to manually yank out gpt4all by cloning the khoj repo and building a modified version of it from scratch 😬

sabaimran commented 10 months ago

Hey @fkgruber , this shouldn't be an issue anymore. When installing Khoj in v0.13.0, it'll skip installing gpt4all if you're machine is Linux & arch is arm. See the relevant commit here: https://github.com/khoj-ai/khoj/commit/2dd15e9f632d045bd7715c25c8dbc8d9423c31e3. This does unfortunately mean you cannot use the offline model, but you should be able to configure your OpenAI key.

You can upgrade by running pip install --upgrade khoj-assistant. Let me know if you experience other issues.

oatmealm commented 5 months ago

does offline work when using the official docker (pre) image? I'm seeing the following from the emacs client...

Contacting host: 127.0.0.1:42110 [2 times]
Chat processor not configured. Configure OpenAI API key and restart it. Exception: [(file-error http://127.0.0.1:42110/api/chat?q=Hello&n=5&client=emacs Internal server error)]
khoj--query-chat-api-and-render-messages: Wrong type argument: listp, "Chat processor not configured. Configure OpenAI API key and restart it. Exception: [(file-error http://127.0.0.1:42110/api/chat?q=Hello&n=5&client=emacs Internal server error)]"

I have a working OpenAI API set up and can chat from the WebUI, but can't do anything from emacs.

When I had khoj installed using pip (outside of docker) offline seem to work.