leejet / stable-diffusion.cpp

Stable Diffusion in pure C/C++
MIT License
2.9k stars 232 forks source link

Prebuild binaries for Android (via Termux) #231

Open SA-j00u opened 2 months ago

SA-j00u commented 2 months ago

leejet doesn't provide binaries for Termux so i put there my own (i'm not linux coder et all)

sd.zip - 2024.04.06 version (it builded with -march native on MT6750 (aarch64) so it may not works on other devices)

not rooted termux can run binaries only from data/data/com.termux/files/usr/bin/ so you need copy it here by command line in same time it can run bash scripts from any folder so you can put you bash script with arguments for SD in any place

example of bash script for SD (it's critical to unix EOL!!!!)

sd      \
--mode txt2img  \
--threads 8 \
--model "/data/data/com.termux/files/home/storage/external-1/models/model.safetensors"  \
--output "/data/data/com.termux/files/home/storage/external-1/file_0000.png"    \
--prompt "1girl, (best quality:1.3), (high quality:1.6), (cute:1.3), (ribbon)"  \
--negative-prompt "(low quality:1.5), (worst quality:1.7)"          \
--cfg-scale 7.0     \
--sampling-method euler \
--steps 15      \
--seed 12345        \
--clip-skip 2       \
-W 512          \
-H 512          \
--type q8_0     \
-v

also be careful CPU is HOT!!!

i wanted to put all binaries that you need install to build stable-diffusion.cpp and single bash script to "make all" offline but I have many issues during offline instalation...

dependencies that not installed in termux from the box (~94MB packed) you can install'em all in this order from top

===============================================================================
        libbz2          already have
        libiconv        already have
        liblzma         already have
        -----------------------------------------------------------------------
            libiconv    already have
            liblzma     already have
            zlib        already have
        libxml2         TO INSTALL
        -----------------------------------------------------------------------
        openssl         already have
        zlib            already have
        ---------------------------------------------------------------
    libarchive
    libarchive_3.7.3_aarch64.deb    TO INSTALL
    -----------------------------------------------------------------------
    libc++              already have
    libcurl             already have
    libexpat            already have
    -----------------------------------------------------------------------
        libc++          already have
    jsoncpp
    jsoncpp_1.9.5-1_aarch64.deb TO INSTALL
    -----------------------------------------------------------------------
    libuv
    libuv_1.48.0_aarch64.deb    TO INSTALL
    -----------------------------------------------------------------------
        openssl         already have
    rhash
    rhash_1.4.4_aarch64.deb     TO INSTALL
    -----------------------------------------------------------------------
    zlib                already have
    -----------------------------------------------------------------------
cmake_3.29.2_aarch64.deb        TO INSTALL
    -----------------------------------------------------------------------
        ca-certificates     already have
        zlib            already have
    libcrypto.so.3
    openssl
    openssl_1_3.2.1-1_aarch64.deb   TO INSTALL
    -----------------------------------------------------------------------
        ca-certificates     already have
        zlib            already have
    libssl.so.1.1
    openssl-1.1
    openssl-1.1_1_1.1.1w_aarch64.deb TO INSTALL TO INSTALL
    -----------------------------------------------------------------------
    openssl-tool_1_3.2.1-1_aarch64.deb      TO INSTALL
    -----------------------------------------------------------------------
        there i manual copy 
        libssl.so.1.1
        libcrypto.so.1.1
        from lib/openssl-1.1/ to lib/
===============================================================================
make_4.4.1_aarch64.deb              TO INSTALL
===============================================================================
        libc++              already have
    libcompiler-rt
    libcompiler-rt_18.1.3_aarch64.deb   TO INSTALL
    -----------------------------------------------------------------------
        libc++              already have
        ---------------------------------------------------------------
        libffi
        libffi_3.4.6-1_aarch64.deb  TO INSTALL
        ---------------------------------------------------------------
        libxml2             already have
        ncurses             already have
        zlib                already have
        ---------------------------------------------------------------
            liblzma
            zlib
        zstd
        zstd_1.5.6_aarch64.deb      TO INSTALL
        ---------------------------------------------------------------
    libllvm (= 18.1.3)
    libllvm_18.1.3_aarch64.deb      TO INSTALL
    -----------------------------------------------------------------------
        libllvm (= 18.1.3)
    lld
    lld_18.1.3_aarch64.deb          TO INSTALL
    -----------------------------------------------------------------------
        libllvm (= 18.1.3)
    llvm
    llvm_18.1.3_aarch64.deb         TO INSTALL
    -----------------------------------------------------------------------
    ndk-sysroot             TO INSTALL
    -----------------------------------------------------------------------
clang_18.1.3_aarch64.deb            TO INSTALL
===============================================================================

termux packages https://packages.termux.dev/apt/termux-main/pool/main/

you can make install.sh with dpkg -i clang_18.1.3_aarch64.deb and run it through bash install.sh

with 3GB ram max resolution that i get is 640x512 (with taesd) and 512x512 with built in vae