netdur / llama_cpp_dart

dart binding for llama.cpp
MIT License
169 stars 22 forks source link

Failed to load dynamic library 'libllama.so' #38

Open Vinayak006 opened 2 months ago

Vinayak006 commented 2 months ago

Description:

I encountered an issue while trying to run my Flutter application using the llama_cpp_dart package. The error occurs when the app attempts to load the libllama.so dynamic library. Below are the details:

Error Message:

Failed to load dynamic library '/libllama.so': dlopen failed: library "/libllama.so" not found
#0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:43)
#1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22:12)
#2      Llama.lib (package:llama_cpp_dart/src/llama.dart:50:41)
#3      new Llama (package:llama_cpp_dart/src/llama.dart:79:5)
#4      LlamaProcessor._modelIsolateEntryPoint.<anonymous closure> (package:llama_cpp_dart/src/llama_processor.dart:122:21)
#5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:365:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)
#8      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#9      _StreamController._add (dart:async/stream_controller.dart:658:7)
#10     _StreamController.add (dart:async/stream_controller.dart:606:5)
#11     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

What I have done is:

  1. Cloned llama.cpp and build libllama.so file.
  2. Placed the libllama.so in root folder of the project and add the library path. Llama.libraryPath = "/llama_cpp_app/libllama.so";
  3. And then I got add_subdirectory(./llama.cpp) issue, so I have did like below:
    cd ~/.pub-cache/hosted/pub.dev/llama_cpp_dart-0.0.4
    git clone https://github.com/ggerganov/llama.cpp.git
  4. When I tried to load model:
    llamaProcessor = LlamaProcessor(
                      path: _modelPathController.text,
                      modelParams: ModelParams(),
                      contextParams: ContextParams(),
                      samplingParams: SamplingParams(),
                    );

    I got the above error: Failed to load dynamic library libllama.so

I dont know where exactly to place the file or Am I missing anything?

netdur commented 2 months ago

did you mean to use ./libllama.so instead of /libllama.so ?

Vinayak006 commented 2 months ago

did you mean to use ./libllama.so instead of /libllama.so ?

I have my libllaam.so file in root folder. I have tried both:

// Using relative path from the lib directory
Llama.libraryPath = "../libllama.so";

Failed to load dynamic library '../libllama.so': dlopen failed: library "../libllama.so" not found
// using absolute path
Llama.libraryPath = "/home/user/projects/llama_cpp/libllama.so";

Failed to load dynamic library '/home/kingkong/YAVAR/projects/llama_cpp_app/libllama.so': dlopen failed: library "/home/kingkong/YAVAR/projects/llama_cpp_app/libllama.so" not found

I don't know what we are missing. Guide us on it @netdur