Open6
Flutter ローカルLLM
llama.cpp
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
Build
Build MacOS
mkdir build
cd build
cmake ..
make
Build iOS (Metal)
mkdir build-metal
cd build-metal
cmake -G Xcode .. \
-DGGML_METAL_USE_BF16=ON \
-DGGML_METAL_EMBED_LIBRARY=ON \
-DLLAMA_BUILD_EXAMPLES=OFF \
-DLLAMA_BUILD_TESTS=OFF \
-DLLAMA_BUILD_SERVER=OFF \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
-DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
Build iOS Simulator
mkdir build-ios-simulator
cd build-ios-simulator
cmake -G Xcode .. \
-DGGML_METAL_USE_BF16=ON \
-DGGML_METAL_EMBED_LIBRARY=ON \
-DLLAMA_BUILD_EXAMPLES=OFF \
-DLLAMA_BUILD_TESTS=OFF \
-DLLAMA_BUILD_SERVER=OFF \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
-DCMAKE_XCODE_ATTRIBUTE_SDKROOT=iphonesimulator
cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
Build Android
mkdir build-android
cd build-android
export NDK=$HOME/Library/Android/sdk/ndk/28.0.12674087
cmake \
-DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-23 \
-DCMAKE_C_FLAGS=-march=armv8.4a+dotprod ..
make
cmake \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-28 \
-DCMAKE_C_FLAGS="-march=armv8.7a" \
-DCMAKE_CXX_FLAGS="-march=armv8.7a" \
-DGGML_OPENMP=OFF \
-DGGML_LLAMAFILE=OFF \
-B build-android
flutter アプリ作成
flutter create flutter_llm_sample
cd flutter_llm_sample
ffi install
flutter pub add ffi
llama_cpp_dart install
flutter pub add llama_cpp_dart
fcllama install
Package / repository
ios/.symlinks/plugins/llama_cpp_dart/ios/llama_cpp_dart.podspec
Pod::Spec.new do |s|
s.name = 'llama_cpp_dart'
s.version = '0.0.1'
s.summary = 'Llama Cpp Dart'
s.homepage = 'https://github.com/netdur/llama_cpp_dart'
s.license = { :type => 'MIT' }
s.author = { 'netdur' => 'team@myteam.com' }
s.source = { :git => '', :version => s.version.to_s }
s.ios.deployment_target = '17.2'
s.macos.deployment_target = '10.15'
# Framework linking is handled by Flutter tooling, not CocoaPods.
# Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
s.vendored_frameworks = 'path/to/nothing'
end