Error when run with docker: error while loading shared libraries: libggml.so
Environment:
MacOS M1 pro
Model:
chatglm2-6b量化模型
Error:
Run with docker
docker run -it --rm -v $PWD:/opt liplusx/chatglm.cpp:main \
./build/bin/main -m /opt/chatglm2-ggml.bin -p "你好"
Error:
./build/bin/main: error while loading shared libraries: libggml.so: cannot open shared object file: No such file or directory
same error in centos 7.6 with both Building Locally and Pre Build Option.
same error in debian11(wsl) with both Building Locally and Pre Build Option.
Same error on WSL2(ubuntu 22.04) with pre build docker image.
Cause of the Issue:
The corresponding executable file main couldn't find the libggml.so file in the system during runtime. Indeed, in the Dockerfile, only the final executable file was copied to the final image, while the dynamic library libggml.so was missed.
Solution:
Modify the Dockerfile. Below the line where the main executable is copied, also copy the libggml.so. The Dockerfile should be updated as follows:
COPY --from=build /chatglm.cpp/build/bin/main /chatglm.cpp/build/bin/main
COPY --from=build /chatglm.cpp/build/lib/libggml.so /chatglm.cpp/build/lib/libggml.so
Rebuild this image and restart to fix this error.