marella / chatdocs

Chat with your documents offline using AI.
MIT License
683 stars 97 forks source link

Error on chat docs download on Raspberry pi #61

Closed PeteInBrissie closed 1 year ago

PeteInBrissie commented 1 year ago

Pi 4B, latest 64-bit lite image.

When I run chat docs download it results in the following:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /home/pete/.local/lib/python3.9/site-packages/chatdocs/main.py:26 in download │ │ │ │ 23 │ from .download import download │ │ 24 │ │ │ 25 │ config = get_config(config) │ │ ❱ 26 │ download(config=config) │ │ 27 │ │ 28 │ │ 29 @app.command() │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ config = { │ │ │ │ │ 'embeddings': {'model': 'hkunlp/instructor-large'}, │ │ │ │ │ 'llm': 'ctransformers', │ │ │ │ │ 'ctransformers': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ │ 'config': {'context_length': 1024, 'local_files_only': False} │ │ │ │ │ }, │ │ │ │ │ 'huggingface': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-HF', │ │ │ │ │ │ 'pipeline_kwargs': {'max_new_tokens': 256} │ │ │ │ │ }, │ │ │ │ │ 'gptq': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GPTQ', │ │ │ │ │ │ 'model_file': │ │ │ │ 'Wizard-Vicuna-7B-Uncensored-GPTQ-4bit-128g.no-act-order.safetensors', │ │ │ │ │ │ 'pipeline_kwargs': {'max_new_tokens': 256} │ │ │ │ │ }, │ │ │ │ │ 'download': False, │ │ │ │ │ 'host': 'localhost', │ │ │ │ │ 'port': 5000, │ │ │ │ │ 'auth': False, │ │ │ │ │ 'chroma': { │ │ │ │ │ │ 'persist_directory': 'db', │ │ │ │ │ │ 'chroma_db_impl': 'duckdb+parquet', │ │ │ │ │ │ 'anonymized_telemetry': False │ │ │ │ │ }, │ │ │ │ │ ... +1 │ │ │ │ } │ │ │ │ download = <function download at 0x7fb1f335e0> │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/pete/.local/lib/python3.9/site-packages/chatdocs/download.py:10 in download │ │ │ │ 7 def download(config: Dict[str, Any]) -> None: │ │ 8 │ config = {config, "download": True} │ │ 9 │ get_embeddings(config) │ │ ❱ 10 │ get_llm(config) │ │ 11 │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ config = { │ │ │ │ │ 'embeddings': {'model': 'hkunlp/instructor-large'}, │ │ │ │ │ 'llm': 'ctransformers', │ │ │ │ │ 'ctransformers': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ │ 'config': {'context_length': 1024, 'local_files_only': False} │ │ │ │ │ }, │ │ │ │ │ 'huggingface': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-HF', │ │ │ │ │ │ 'pipeline_kwargs': {'max_new_tokens': 256} │ │ │ │ │ }, │ │ │ │ │ 'gptq': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GPTQ', │ │ │ │ │ │ 'model_file': │ │ │ │ 'Wizard-Vicuna-7B-Uncensored-GPTQ-4bit-128g.no-act-order.safetensors', │ │ │ │ │ │ 'pipeline_kwargs': {'max_new_tokens': 256} │ │ │ │ │ }, │ │ │ │ │ 'download': True, │ │ │ │ │ 'host': 'localhost', │ │ │ │ │ 'port': 5000, │ │ │ │ │ 'auth': False, │ │ │ │ │ 'chroma': { │ │ │ │ │ │ 'persist_directory': 'db', │ │ │ │ │ │ 'chroma_db_impl': 'duckdb+parquet', │ │ │ │ │ │ 'anonymized_telemetry': False │ │ │ │ │ }, │ │ │ │ │ ... +1 │ │ │ │ } │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/pete/.local/lib/python3.9/site-packages/chatdocs/llms.py:73 in get_llm │ │ │ │ 70 │ if config["llm"] == "ctransformers": │ │ 71 │ │ config = {config["ctransformers"]} │ │ 72 │ │ config = merge(config, {"config": {"local_files_only": local_files_only}}) │ │ ❱ 73 │ │ llm = CTransformers(callbacks=callbacks, config) │ │ 74 │ elif config["llm"] == "gptq": │ │ 75 │ │ llm = get_gptq_llm(config) │ │ 76 │ else: │ │ │ │ ╭─────────────────────────────────────── locals ───────────────────────────────────────╮ │ │ │ callback = None │ │ │ │ CallbackHandler = <class 'chatdocs.llms.get_llm..CallbackHandler'> │ │ │ │ callbacks = None │ │ │ │ config = { │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ 'config': { │ │ │ │ │ │ 'context_length': 1024, │ │ │ │ │ │ 'local_files_only': False │ │ │ │ │ } │ │ │ │ } │ │ │ │ local_files_only = False │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/pete/.local/lib/python3.9/site-packages/langchain/load/serializable.py:74 in init │ │ │ │ 71 │ _lc_kwargs = PrivateAttr(default_factory=dict) │ │ 72 │ │ │ 73 │ def init(self, kwargs: Any) -> None: │ │ ❱ 74 │ │ super().init(**kwargs) │ │ 75 │ │ self._lc_kwargs = kwargs │ │ 76 │ │ │ 77 │ def to_json(self) -> Union[SerializedConstructor, SerializedNotImplemented]: │ │ │ │ ╭─────────────────────────────────── locals ────────────────────────────────────╮ │ │ │ class = <class 'langchain.load.serializable.Serializable'> │ │ │ │ kwargs = { │ │ │ │ │ 'callbacks': None, │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ 'config': { │ │ │ │ │ │ 'context_length': 1024, │ │ │ │ │ │ 'local_files_only': False │ │ │ │ │ } │ │ │ │ } │ │ │ │ self = CTransformers() │ │ │ ╰───────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/pete/.local/lib/python3.9/site-packages/pydantic/main.py:339 in init │ │ │ │ 336 │ │ Raises ValidationError if the input data cannot be parsed to form a valid model. │ │ 337 │ │ """ │ │ 338 │ │ # Uses something other than self the first arg to allow "self" as a settable a │ │ ❱ 339 │ │ values, fields_set, validation_error = validate_model(pydanticself.class │ │ 340 │ │ if validation_error: │ │ 341 │ │ │ raise validation_error │ │ 342 │ │ try: │ │ │ │ ╭─────────────────────────────────────── locals ────────────────────────────────────────╮ │ │ │ pydantic_self = CTransformers() │ │ │ │ data = { │ │ │ │ │ 'callbacks': None, │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ 'config': { │ │ │ │ │ │ 'context_length': 1024, │ │ │ │ │ │ 'local_files_only': False │ │ │ │ │ } │ │ │ │ } │ │ │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/pete/.local/lib/python3.9/site-packages/pydantic/main.py:1102 in validate_model │ │ │ │ 1099 │ │ if skip_onfailure and errors: │ │ 1100 │ │ │ continue │ │ 1101 │ │ try: │ │ ❱ 1102 │ │ │ values = validator(cls, values) │ │ 1103 │ │ except (ValueError, TypeError, AssertionError) as exc: │ │ 1104 │ │ │ errors.append(ErrorWrapper(exc, loc=ROOT_KEY)) │ │ 1105 │ │ │ │ ╭────────────────────────────────────────── locals ──────────────────────────────────────────╮ │ │ │ checkextra = False │ │ │ │ cls = None │ │ │ │ cls = <class 'langchain.llms.ctransformers.CTransformers'> │ │ │ │ config = <class 'pydantic.config.Config'> │ │ │ │ errors = [] │ │ │ │ errors_ = None │ │ │ │ field = ModelField(name='lib', type=Optional[str], required=False, default=None) │ │ │ │ fields_set = {'config', 'callbacks', 'model_file', 'model_type', 'model'} │ │ │ │ input_data = { │ │ │ │ │ 'callbacks': None, │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ 'config': {'context_length': 1024, 'local_files_only': False} │ │ │ │ } │ │ │ │ model = <class 'langchain.llms.ctransformers.CTransformers'> │ │ │ │ name = 'lib' │ │ │ │ names_used = set() │ │ │ │ skip_on_failure = False │ │ │ │ usingname = False │ │ │ │ v = {'context_length': 1024, 'local_files_only': False} │ │ │ │ validator = <function CTransformers.validate_environment at 0x7fa6240a60> │ │ │ │ value = None │ │ │ │ values = { │ │ │ │ │ 'cache': None, │ │ │ │ │ 'verbose': False, │ │ │ │ │ 'callbacks': None, │ │ │ │ │ 'callback_manager': None, │ │ │ │ │ 'tags': None, │ │ │ │ │ 'metadata': None, │ │ │ │ │ 'client': None, │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ ... +2 │ │ │ │ } │ │ │ ╰────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/pete/.local/lib/python3.9/site-packages/langchain/llms/ctransformers.py:73 in │ │ validate_environment │ │ │ │ 70 │ │ │ ) │ │ 71 │ │ │ │ 72 │ │ config = values["config"] or {} │ │ ❱ 73 │ │ values["client"] = AutoModelForCausalLM.from_pretrained( │ │ 74 │ │ │ values["model"], │ │ 75 │ │ │ model_type=values["model_type"], │ │ 76 │ │ │ model_file=values["model_file"], │ │ │ │ ╭──────────────────────────────────────── locals ─────────────────────────────────────────╮ │ │ │ AutoModelForCausalLM = <class 'ctransformers.hub.AutoModelForCausalLM'> │ │ │ │ cls = <class 'langchain.llms.ctransformers.CTransformers'> │ │ │ │ config = {'context_length': 1024, 'local_files_only': False} │ │ │ │ values = { │ │ │ │ │ 'cache': None, │ │ │ │ │ 'verbose': False, │ │ │ │ │ 'callbacks': None, │ │ │ │ │ 'callback_manager': None, │ │ │ │ │ 'tags': None, │ │ │ │ │ 'metadata': None, │ │ │ │ │ 'client': None, │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ ... +2 │ │ │ │ } │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/pete/.local/lib/python3.9/site-packages/ctransformers/hub.py:168 in from_pretrained │ │ │ │ 165 │ │ │ │ local_files_only=local_files_only, │ │ 166 │ │ │ ) │ │ 167 │ │ │ │ ❱ 168 │ │ return LLM( │ │ 169 │ │ │ model_path=model_path, │ │ 170 │ │ │ model_type=model_type, │ │ 171 │ │ │ config=config.config, │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ cls = <class 'ctransformers.hub.AutoModelForCausalLM'> │ │ │ │ config = AutoConfig( │ │ │ │ │ config=Config( │ │ │ │ │ │ top_k=40, │ │ │ │ │ │ top_p=0.95, │ │ │ │ │ │ temperature=0.8, │ │ │ │ │ │ repetition_penalty=1.1, │ │ │ │ │ │ last_n_tokens=64, │ │ │ │ │ │ seed=-1, │ │ │ │ │ │ batch_size=8, │ │ │ │ │ │ threads=-1, │ │ │ │ │ │ max_new_tokens=256, │ │ │ │ │ │ stop=None, │ │ │ │ │ │ stream=False, │ │ │ │ │ │ reset=True, │ │ │ │ │ │ context_length=1024, │ │ │ │ │ │ gpu_layers=0 │ │ │ │ │ ), │ │ │ │ │ model_type=None │ │ │ │ ) │ │ │ │ kwargs = {'context_length': 1024} │ │ │ │ lib = None │ │ │ │ local_files_only = False │ │ │ │ model_file = 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin' │ │ │ │ model_path = '/home/pete/.cache/huggingface/hub/models--TheBloke--Wizard-Vicuna-… │ │ │ │ model_path_or_repo_id = 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML' │ │ │ │ model_type = 'llama' │ │ │ │ path_type = 'repo' │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/pete/.local/lib/python3.9/site-packages/ctransformers/llm.py:206 in init │ │ │ │ 203 │ │ if not Path(model_path).is_file(): │ │ 204 │ │ │ raise ValueError(f"Model path '{model_path}' doesn't exist.") │ │ 205 │ │ │ │ ❱ 206 │ │ self._lib = load_library(lib, cuda=config.gpu_layers > 0) │ │ 207 │ │ self._llm = self._lib.ctransformers_llm_create( │ │ 208 │ │ │ model_path.encode(), │ │ 209 │ │ │ model_type.encode(), │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ config = Config( │ │ │ │ │ top_k=40, │ │ │ │ │ top_p=0.95, │ │ │ │ │ temperature=0.8, │ │ │ │ │ repetition_penalty=1.1, │ │ │ │ │ last_n_tokens=64, │ │ │ │ │ seed=-1, │ │ │ │ │ batch_size=8, │ │ │ │ │ threads=-1, │ │ │ │ │ max_new_tokens=256, │ │ │ │ │ stop=None, │ │ │ │ │ stream=False, │ │ │ │ │ reset=True, │ │ │ │ │ context_length=1024, │ │ │ │ │ gpu_layers=0 │ │ │ │ ) │ │ │ │ lib = None │ │ │ │ model_path = '/home/pete/.cache/huggingface/hub/models--TheBloke--Wizard-Vicuna-7B-Uncensor… │ │ │ │ model_type = 'llama' │ │ │ │ self = <ctransformers.llm.LLM object at 0x7f86646340> │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/pete/.local/lib/python3.9/site-packages/ctransformers/llm.py:102 in load_library │ │ │ │ 99 │ │ os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "bin")) │ │ 100 │ │ │ 101 │ path = find_library(path, cuda=cuda) │ │ ❱ 102 │ lib = CDLL(path) │ │ 103 │ │ │ 104 │ lib.ctransformers_llm_create.argtypes = [ │ │ 105 │ │ c_char_p, # model_path │ │ │ │ ╭────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ cuda = False │ │ │ │ path = '/home/pete/.local/lib/python3.9/site-packages/ctransformers/lib/basic/libctransf'+9 │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/lib/python3.9/ctypes/init.py:374 in init__ │ │ │ │ 371 │ │ self._FuncPtr = _FuncPtr │ │ 372 │ │ │ │ 373 │ │ if handle is None: │ │ ❱ 374 │ │ │ self._handle = _dlopen(self._name, mode) │ │ 375 │ │ else: │ │ 376 │ │ │ self._handle = handle │ │ 377 │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ _FuncPtr = <class 'ctypes.CDLL.init.._FuncPtr'> │ │ │ │ flags = 1 │ │ │ │ handle = None │ │ │ │ mode = 0 │ │ │ │ name = '/home/pete/.local/lib/python3.9/site-packages/ctransformers/lib/basic/lib… │ │ │ │ self = <CDLL │ │ │ │ '/home/pete/.local/lib/python3.9/site-packages/ctransformers/lib/basic/lib… │ │ │ │ handle 0 at 0x7fa32b6940> │ │ │ │ use_errno = False │ │ │ │ use_last_error = False │ │ │ │ winmode = None │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ OSError: /home/pete/.local/lib/python3.9/site-packages/ctransformers/lib/basic/libctransformers.so: cannot open shared object file: No such file or directory

The folder in question contains the file:

pete@raspberrypi:~ $ ls -lisa /home/pete/.local/lib/python3.9/site-packages/ctransformers/lib/basic total 4296 273689 4 drwxr-xr-x 2 pete pete 4096 Aug 5 09:49 . 273680 4 drwxr-xr-x 6 pete pete 4096 Aug 5 09:49 .. 273690 1056 -rw-r--r-- 1 pete pete 1078784 Aug 5 09:49 ctransformers.dll 273691 2060 -rw-r--r-- 1 pete pete 2105843 Aug 5 09:49 libctransformers.dylib 273692 1172 -rw-r--r-- 1 pete pete 1198416 Aug 5 09:49 libctransformers.so

I've been stuck here for a week - any help appreciated. Thanks.

PeteInBrissie commented 1 year ago

It seems to be that the file is compiled for x86. See below. Any chance of an ARM version?

pete@raspberrypi:~ $ file /home/pete/.local/lib/python3.9/site-packages/ctransformers/lib/basic/libctransformers.so /home/pete/.local/lib/python3.9/site-packages/ctransformers/lib/basic/libctransformers.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=b099284d79694da7ff4111126309838fb62e60c7, not stripped

PeteInBrissie commented 1 year ago

Never mind - successfully running on a VM instead

marella commented 1 year ago

Precompiled binaries for ctransformers package are not available for ARM processors but you can install and build from source using:

pip uninstall ctransformers --yes # uninstall if already installed
pip install ctransformers --no-binary ctransformers # install and build binaries locally