]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
readme : add steps for Android compilation and inference (#664)
authorMayank Kumar Pal <redacted>
Fri, 29 Dec 2023 07:35:19 +0000 (13:05 +0530)
committerGitHub <redacted>
Fri, 29 Dec 2023 07:35:19 +0000 (09:35 +0200)
* Update README.md for android instructions

* fix minor typo

README.md

index 68d387e8df130c906861eb59f58b47691c3f62d5..efdc59cd7a3d42e8306134109ca05c794410daac 100644 (file)
--- a/README.md
+++ b/README.md
@@ -134,6 +134,42 @@ cmake -DGGML_CUBLAS=ON -DCMAKE_CUDA_COMPILER=/usr/local/cuda-12.1/bin/nvcc ..
 ```bash
 cmake -DGGML_CLBLAST=ON ..
 ```
+## Compiling for Android
+
+Download and unzip the NDK from this download [page](https://developer.android.com/ndk/downloads). Set the NDK_ROOT_PATH environment variable or provide the absolute path to the CMAKE_ANDROID_NDK in the command below.
+
+```bash
+cmake .. \
+   -DCMAKE_SYSTEM_NAME=Android \
+   -DCMAKE_SYSTEM_VERSION=33 \
+   -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \
+   -DCMAKE_ANDROID_NDK=$NDK_ROOT_PATH
+   -DCMAKE_ANDROID_STL_TYPE=c++_shared 
+```
+
+```bash
+# Create directories
+adb shell 'mkdir /data/local/tmp/bin'
+adb shell 'mkdir /data/local/tmp/models'
+
+# Push the compiled binaries to the folder
+adb push bin/* /data/local/tmp/bin/
+
+# Push the ggml library
+adb push src/libggml.so /data/local/tmp/
+
+# Push model files
+adb push models/gpt-2-117M/ggml-model.bin /data/local/tmp/models/
+
+
+# Now lets do some inference ...
+adb shell
+
+# Now we are in shell
+cd /data/local/tmp
+export LD_LIBRARY_PATH=/data/local/tmp
+./bin/gpt-2-backend -m models/ggml-model.bin -p "this is an example"
+```
 
 ## Resources