Repository: mudler/LocalAI

Issue #1196: compilation fails for "examples/grpc-server"
Created: 2023-10-19T10:29:18Z
LocalAI version:

45370c2
Environment, CPU architecture, OS, and Version:

Linux fedora 6.5.6-300.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Oct  6 19:57:21 UTC 2023 x86_64 GNU/Linux
Describe the bug

After failures with CUDA and docker in
#1178
I try to compile and run LocalAI directly on the host: make BUILD_TYPE=cublas build
To Reproduce

make BUILD_TYPE=cublas build
Expected behavior

Successful build, binaries running with CUDA support
Logs

make -C go-llama BUILD_TYPE=cublas libbinding.a
make[1]: Verzeichnis „/home/sgw/LocalAI/go-llama“ wird betreten
I llama.cpp build info: 
I UNAME_S:  Linux
I UNAME_P:  unknown
I UNAME_M:  x86_64
I CFLAGS:   -I./llama.cpp -I. -O3 -DNDEBUG -std=c11 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -Wno-unused-function -pthread -march=native -mtune=native
I CXXFLAGS: -I./llama.cpp -I. -I./llama.cpp/common -I./common -O3 -DNDEBUG -std=c++11 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -pthread
I CGO_LDFLAGS:  
I LDFLAGS:  
I BUILD_TYPE:  cublas
I CMAKE_ARGS:  -DLLAMA_AVX512=OFF -DLLAMA_CUBLAS=ON
I EXTRA_TARGETS:  llama.cpp/ggml-cuda.o
I CC:       cc (GCC) 13.2.1 20230918 (Red Hat 13.2.1-3)
I CXX:      g++ (GCC) 13.2.1 20230918 (Red Hat 13.2.1-3)

make[1]: „libbinding.a“ ist bereits aktuell.
make[1]: Verzeichnis „/home/sgw/LocalAI/go-llama“ wird verlassen
LLAMA_VERSION=24ba3d829e31a6eda3fa1723f692608c2fa3adda make -C backend/cpp/llama grpc-server
make[1]: Verzeichnis „/home/sgw/LocalAI/backend/cpp/llama“ wird betreten
cd llama.cpp && mkdir -p build && cd build && cmake .. -DLLAMA_AVX512=OFF -DLLAMA_CUBLAS=ON && cmake --build . --config Release
-- cuBLAS found
-- Using CUDA architectures: 52;61;70
-- CMAKE_SYSTEM_PROCESSOR: x86_64
-- x86 detected
CMake Error at examples/grpc-server/CMakeLists.txt:7 (find_package):
  Could not find a package configuration file provided by "absl" with any of
  the following names:

    abslConfig.cmake
    absl-config.cmake

  Add the installation prefix of "absl" to CMAKE_PREFIX_PATH or set
  "absl_DIR" to a directory containing one of the above files.  If "absl"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
make[1]: *** [Makefile:43: grpc-server] Fehler 1
make[1]: Verzeichnis „/home/sgw/LocalAI/backend/cpp/llama“ wird verlassen

Additional context

I also tried CMAKE_ARGS="-DLLAMA_AVX512=OFF"  make BUILD_TYPE=cublas build because my CPU doesn't support AVX512.
Maybe interesting:
$ gcc -v
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Ziel: x86_64-redhat-linux
Konfiguriert mit: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.2.1-20230918/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread-Modell: posix
Unterstützte LTO-Kompressionsalgorithmen: zlib zstd
gcc-Version 13.2.1 20230918 (Red Hat 13.2.1-3) (GCC)

But the error message seems more like something is missing than it's the wrong gcc.
EDIT: search for absl, found and installed sudo dnf install python3-absl-py.noarch ... doesn't help.

Duplicate issue #1386: can't build backend/cpp/llama, cmake can't find protobuf
Created: 2023-12-04T22:02:50Z
LocalAI version:
commit 67966b6
Environment, CPU architecture, OS, and Version:
AMD Ryzen 7 7840HS with Radeon 780M Graphics
Linux cappuccino 6.1.0-13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 GNU/Linux
Devuan GNU/Linux 5 (daedalus) #Based on Debian Bookworm (version 12) with Linux kernel 6.1
Describe the bug
Even after installing various libproto*-dev, cmake can't find protobuf. Unfortunately I'm not familiar with C++ to help myself further.
To Reproduce
make clean
make build #until it fails
cd backend/cpp/llama
make rebuild
Expected behavior
Builds with the available Protobuf library packages
Logs
$ make rebuild
cp -rfv /home/dionysius/Projects/github.com/mudler/LocalAI/backend/cpp/llama/CMakeLists.txt llama.cpp/examples/grpc-server/
'/home/dionysius/Projects/github.com/mudler/LocalAI/backend/cpp/llama/CMakeLists.txt' -> 'llama.cpp/examples/grpc-server/CMakeLists.txt'
cp -rfv /home/dionysius/Projects/github.com/mudler/LocalAI/backend/cpp/llama/grpc-server.cpp llama.cpp/examples/grpc-server/
'/home/dionysius/Projects/github.com/mudler/LocalAI/backend/cpp/llama/grpc-server.cpp' -> 'llama.cpp/examples/grpc-server/grpc-server.cpp'
cp -rfv /home/dionysius/Projects/github.com/mudler/LocalAI/backend/cpp/llama/json.hpp llama.cpp/examples/grpc-server/
'/home/dionysius/Projects/github.com/mudler/LocalAI/backend/cpp/llama/json.hpp' -> 'llama.cpp/examples/grpc-server/json.hpp'
rm -rf grpc-server
make grpc-server
make[1]: Entering directory '/home/dionysius/Projects/github.com/mudler/LocalAI/backend/cpp/llama'
cd llama.cpp && mkdir -p build && cd build && cmake ..  && cmake --build . --config Release
-- CMAKE_SYSTEM_PROCESSOR: x86_64
-- x86 detected
CMake Error at examples/grpc-server/CMakeLists.txt:26 (find_package):
  Could not find a package configuration file provided by "Protobuf" with any
  of the following names:

    ProtobufConfig.cmake
    protobuf-config.cmake

  Add the installation prefix of "Protobuf" to CMAKE_PREFIX_PATH or set
  "Protobuf_DIR" to a directory containing one of the above files.  If
  "Protobuf" provides a separate development package or SDK, be sure it has
  been installed.


-- Configuring incomplete, errors occurred!
See also "/home/dionysius/Projects/github.com/mudler/LocalAI/backend/cpp/llama/llama.cpp/build/CMakeFiles/CMakeOutput.log".
make[1]: *** [Makefile:49: grpc-server] Error 1
make[1]: Leaving directory '/home/dionysius/Projects/github.com/mudler/LocalAI/backend/cpp/llama'
make: *** [Makefile:42: rebuild] Error 2
Additional context
Related to #1196, but I am only stuck with protobuf, installing libabsl-dev and other required libraries fixed previous errors.
I can build https://github.com/ggerganov/llama.cpp itself without error.
I can't find which libproto should be installed, the search only yields the CMakeLists.txt where it's used.
I have not set any gpu toolset in any env. I expect running on CPU for helping fixing go related bugs and features should be fine and/or can rebuild with gpu support later.
Installed packages:
$ dpkg -l | grep libproto
ii  libprotobuf-c-dev:amd64                                     1.4.1-1+b1                          amd64        Protocol Buffers C static library and headers (protobuf-c)
ii  libprotobuf-c1:amd64                                        1.4.1-1+b1                          amd64        Protocol Buffers C shared library (protobuf-c)
ii  libprotobuf-dev:amd64                                       3.21.12-3                           amd64        protocol buffers C++ library (development files) and proto files
ii  libprotobuf-lite32:amd64                                    3.21.12-3                           amd64        protocol buffers C++ library (lite version)
ii  libprotobuf32:amd64                                         3.21.12-3                           amd64        protocol buffers C++ library
ii  libprotoc-dev:amd64                                         3.21.12-3                           amd64        protocol buffers compiler library (development files)
ii  libprotoc32:amd64                                           3.21.12-3                           amd64        protocol buffers compiler library
ii  libprotozero-dev                                            1.7.1-1                             amd64        Minimalistic protocol buffer decoder and encoder in C++

what cmake FindProtobuf tells me:
$ cmake --help-module FindProtobuf
FindProtobuf
------------

Locate and configure the Google Protocol Buffers library.

.. versionadded:: 3.6
  Support for ``find_package()`` version checks.

.. versionchanged:: 3.6
  All input and output variables use the ``Protobuf_`` prefix.
  Variables with ``PROTOBUF_`` prefix are still supported for compatibility.

The following variables can be set and are optional:

``Protobuf_SRC_ROOT_FOLDER``
  When compiling with MSVC, if this cache variable is set
  the protobuf-default VS project build locations
  (vsprojects/Debug and vsprojects/Release
  or vsprojects/x64/Debug and vsprojects/x64/Release)
  will be searched for libraries and binaries.
``Protobuf_IMPORT_DIRS``
  List of additional directories to be searched for
  imported .proto files.
``Protobuf_DEBUG``
  .. versionadded:: 3.6

  Show debug messages.
``Protobuf_USE_STATIC_LIBS``
  .. versionadded:: 3.9

  Set to ON to force the use of the static libraries.
  Default is OFF.

Defines the following variables:

``Protobuf_FOUND``
  Found the Google Protocol Buffers library
  (libprotobuf & header files)
``Protobuf_VERSION``
  .. versionadded:: 3.6

  Version of package found.
``Protobuf_INCLUDE_DIRS``
  Include directories for Google Protocol Buffers
``Protobuf_LIBRARIES``
  The protobuf libraries
``Protobuf_PROTOC_LIBRARIES``
  The protoc libraries
``Protobuf_LITE_LIBRARIES``
  The protobuf-lite libraries

.. versionadded:: 3.9
  The following ``IMPORTED`` targets are also defined:

``protobuf::libprotobuf``
  The protobuf library.
``protobuf::libprotobuf-lite``
  The protobuf lite library.
``protobuf::libprotoc``
  The protoc library.
``protobuf::protoc``
  .. versionadded:: 3.10
    The protoc compiler.

The following cache variables are also available to set or use:

``Protobuf_LIBRARY``
  The protobuf library
``Protobuf_PROTOC_LIBRARY``
  The protoc library
``Protobuf_INCLUDE_DIR``
  The include directory for protocol buffers
``Protobuf_PROTOC_EXECUTABLE``
  The protoc compiler
``Protobuf_LIBRARY_DEBUG``
  The protobuf library (debug)
``Protobuf_PROTOC_LIBRARY_DEBUG``
  The protoc library (debug)
``Protobuf_LITE_LIBRARY``
  The protobuf lite library
``Protobuf_LITE_LIBRARY_DEBUG``
  The protobuf lite library (debug)

Example:

 find_package(Protobuf REQUIRED)
 include_directories(${Protobuf_INCLUDE_DIRS})
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS foo.proto)
 protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS EXPORT_MACRO DLL_EXPORT foo.proto)
 protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS DESCRIPTORS PROTO_DESCS foo.proto)
 protobuf_generate_python(PROTO_PY foo.proto)
 add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS})
 target_link_libraries(bar ${Protobuf_LIBRARIES})

.. note::
  The ``protobuf_generate_cpp`` and ``protobuf_generate_python``
  functions and ``add_executable()`` or ``add_library()``
  calls only work properly within the same directory.

.. command:: protobuf_generate_cpp

  Add custom commands to process ``.proto`` files to C++::

   protobuf_generate_cpp (<SRCS> <HDRS>
       [DESCRIPTORS <DESC>] [EXPORT_MACRO <MACRO>] [<ARGN>...])

 ``SRCS``
   Variable to define with autogenerated source files
 ``HDRS``
   Variable to define with autogenerated header files
 ``DESCRIPTORS``
   .. versionadded:: 3.10
     Variable to define with autogenerated descriptor files, if requested.
 ``EXPORT_MACRO``
   is a macro which should expand to ``__declspec(dllexport)`` or
   ``__declspec(dllimport)`` depending on what is being compiled.
 ``ARGN``
   ``.proto`` files

.. command:: protobuf_generate_python

  .. versionadded:: 3.4

  Add custom commands to process ``.proto`` files to Python::

   protobuf_generate_python (<PY> [<ARGN>...])

 ``PY``
   Variable to define with autogenerated Python files
 ``ARGN``
   ``.proto`` files

Closing comment (2023-12-11T13:10:47Z): Thank you, this BUILD_GRPC_FOR_BACKEND_LLAMA=ON did the trick! I'm confused how I did not see that as my linked issue discussed that part. Well then this issue is just a duplicate of #1196