Merge 759dcdcfdb
into ea2c85d5d2
This commit is contained in:
commit
72621682c8
1 changed files with 37 additions and 26 deletions
63
README.md
63
README.md
|
@ -804,48 +804,59 @@ Finally, copy the `llama` binary and the model files to your device storage. Her
|
||||||
|
|
||||||
https://user-images.githubusercontent.com/271616/225014776-1d567049-ad71-4ef2-b050-55b0b3b9274c.mp4
|
https://user-images.githubusercontent.com/271616/225014776-1d567049-ad71-4ef2-b050-55b0b3b9274c.mp4
|
||||||
|
|
||||||
#### Building the Project using Termux (F-Droid)
|
#### Building the Project in Termux (F-Droid)
|
||||||
Termux from F-Droid offers an alternative route to execute the project on an Android device. This method empowers you to construct the project right from within the terminal, negating the requirement for a rooted device or SD Card.
|
[Termux](https://termux.dev/) is a way to run `llama.cpp` on Android devices.
|
||||||
|
|
||||||
Outlined below are the directives for installing the project using OpenBLAS and CLBlast. This combination is specifically designed to deliver peak performance on recent devices that feature a GPU.
|
Ensure Termux is up to date and clone the repo:
|
||||||
|
|
||||||
If you opt to utilize OpenBLAS, you'll need to install the corresponding package.
|
|
||||||
```
|
```
|
||||||
apt install libopenblas
|
apt update && apt upgrade
|
||||||
|
cd
|
||||||
|
git clone https://github.com/ggerganov/llama.cpp
|
||||||
```
|
```
|
||||||
|
|
||||||
Subsequently, if you decide to incorporate CLBlast, you'll first need to install the requisite OpenCL packages:
|
Build `llama.cpp`:
|
||||||
```
|
```
|
||||||
apt install ocl-icd opencl-headers opencl-clhpp clinfo
|
cd llama.cpp
|
||||||
```
|
|
||||||
|
|
||||||
In order to compile CLBlast, you'll need to first clone the respective Git repository, which can be found at this URL: https://github.com/CNugteren/CLBlast. Alongside this, clone this repository into your home directory. Once this is done, navigate to the CLBlast folder and execute the commands detailed below:
|
|
||||||
```
|
|
||||||
cmake .
|
|
||||||
make
|
make
|
||||||
cp libclblast.so* $PREFIX/lib
|
|
||||||
cp ./include/clblast.h ../llama.cpp
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Following the previous steps, navigate to the LlamaCpp directory. To compile it with OpenBLAS and CLBlast, execute the command provided below:
|
It's possible to enable `OpenBlas` while building:
|
||||||
```
|
```
|
||||||
cp /data/data/com.termux/files/usr/include/openblas/cblas.h .
|
pkg install libopenblas
|
||||||
cp /data/data/com.termux/files/usr/include/openblas/openblas_config.h .
|
cd llama.cpp
|
||||||
make LLAMA_CLBLAST=1 //(sometimes you need to run this command twice)
|
make LLAMA_OPENBLAS=1
|
||||||
```
|
```
|
||||||
|
|
||||||
Upon completion of the aforementioned steps, you will have successfully compiled the project. To run it using CLBlast, a slight adjustment is required: a command must be issued to direct the operations towards your device's physical GPU, rather than the virtual one. The necessary command is detailed below:
|
Move your model to the home directory (`~/`), for example:
|
||||||
```
|
```
|
||||||
GGML_OPENCL_PLATFORM=0
|
cd
|
||||||
GGML_OPENCL_DEVICE=0
|
cd storage/downloads
|
||||||
export LD_LIBRARY_PATH=/vendor/lib64:$LD_LIBRARY_PATH
|
mv 7b-model.gguf.q4_0.bin ~/
|
||||||
```
|
```
|
||||||
|
|
||||||
(Note: some Android devices, like the Zenfone 8, need the following command instead - "export LD_LIBRARY_PATH=/system/vendor/lib64:$LD_LIBRARY_PATH". Source: https://www.reddit.com/r/termux/comments/kc3ynp/opencl_working_in_termux_more_in_comments/ )
|
Usage example:
|
||||||
|
```
|
||||||
|
./main -m ~/7b-model.gguf.q4_0.bin --color -c 2048 --keep -1 -n -2 -b 7 -ins -p 'Below is an instruction that describes a task. Write a response that appropriately completes the request.'\n\n'### Instruction:'\n'Hi!'\n\n'### Response:Hi! How may I assist you?'
|
||||||
|
```
|
||||||
|
|
||||||
For easy and swift re-execution, consider documenting this final part in a .sh script file. This will enable you to rerun the process with minimal hassle.
|
For building with `OpenCL` then install the requisite packages:
|
||||||
|
```
|
||||||
|
pkg install ocl-icd opencl-headers clblast
|
||||||
|
cd llama.cpp
|
||||||
|
make LLAMA_CLBLAST=1
|
||||||
|
```
|
||||||
|
|
||||||
Place your desired model into the `~/llama.cpp/models/` directory and execute the `./main (...)` script.
|
Use one of the following to enable GPU:
|
||||||
|
```
|
||||||
|
export LD_LIBRARY_PATH=/vendor/lib64
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```
|
||||||
|
export LD_LIBRARY_PATH=/system/vendor/lib64
|
||||||
|
```
|
||||||
|
then `./main ... --gpu-layers 1`
|
||||||
|
|
||||||
|
(Note: Use `unset LD_LIBRARY_PATH` to re-link executables.)
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue