[Python] Python gpt4all gives error for libllama.so python:3.12-slim image

Discussão em 'Python' iniciado por Stack, Agosto 1, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use gpt4all in python:3.12-slim image.

    I created Dockerfile as below.

    FROM python:3.12-slim

    RUN pip install setuptools gpt4all

    CMD ["python", "-c", "from gpt4all import GPT4All"]


    I created test image with docker build command

    % docker build . -t test
    [+] Building 4.0s (6/6) FINISHED docker:desktop-linux
    => [internal] load build definition from Dockerfile 0.0s
    => => transferring dockerfile: 148B 0.0s
    => [internal] load metadata for docker.io/library/python:3.12-slim 0.0s
    => [internal] load .dockerignore 0.0s
    => => transferring context: 1.03kB 0.0s
    => CACHED [1/2] FROM docker.io/library/python:3.12-slim 0.0s
    => [2/2] RUN pip install setuptools gpt4all 3.8s
    => exporting to image 0.1s
    => => exporting layers 0.1s
    => => writing image sha256:747f24854515a3d6583e930365d66553b79b30a2ccb180320fc399c349f670c5 0.0s
    => => naming to docker.io/library/test 0.0s

    View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/1b9h0ans5zepm7k3enx62enpa


    When try to run, it gives error.

    % docker run --rm test
    /usr/local/lib/python3.12/site-packages/gpt4all/pyllmodel.py:2: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
    import pkg_resources
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/usr/local/lib/python3.12/site-packages/gpt4all/__init__.py", line 1, in <module>
    from . import gpt4all # noqa
    ^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/gpt4all/gpt4all.py", line 6, in <module>
    from . import pyllmodel
    File "/usr/local/lib/python3.12/site-packages/gpt4all/pyllmodel.py", line 39, in <module>
    llmodel, llama = load_llmodel_library()
    ^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/gpt4all/pyllmodel.py", line 32, in load_llmodel_library
    llama_lib = ctypes.CDLL(llama_dir, mode=ctypes.RTLD_GLOBAL)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/ctypes/__init__.py", line 379, in __init__
    self._handle = _dlopen(self._name, mode)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    OSError: /usr/local/lib/python3.12/site-packages/gpt4all/llmodel_DO_NOT_MODIFY/build/libllama.so: cannot open shared object file: No such file or directory


    Without docker image, it works fine on Mac M1.

    I tried RUN apt-get install -y liblzma-dev in the Dockerfile but that doesn't help.

    How to makes sure this libllama.so is available in docker image?

    Continue reading...

Compartilhe esta Página