SLM750-Edge-1.58-bit / BitNet /bitnet_auto_install.sh
Qapdex's picture
Rename BitNet/files.sh/bitnet_auto_install.sh to BitNet/bitnet_auto_install.sh
3205d30 verified
Raw
History Blame Contribute Delete
2.24 kB
#!/usr/bin/env bash
set -euo pipefail
LOGFILE="$HOME/bitnet_install_$(date +%Y%m%d_%H%M%S).log"
exec > >(awk '{ print strftime("[%Y-%m-%d %H:%M:%S]"), $0; fflush(); }' | tee -a "$LOGFILE") 2>&1
echo "=== BitNet Auto-Installer gestartet ==="
echo "Logdatei: $LOGFILE"
echo
# --- System prep. ---
pkg update -y && pkg upgrade -y
pkg install clang cmake make git pkg-config python libffi openssl freetype libpng libjpeg-turbo zlib ninja rust moreutils -y
ln -sf /system/lib64/liblog.so $PREFIX/lib/liblog.so 2>/dev/null || true
export LDFLAGS="-llog"
export CXXFLAGS="-fPIC"
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
# --- Python-Toolchain ---
python3 -m pip install --upgrade setuptools wheel build pybind11
# --- SentencePiece Build ---
echo "=== Building SentencePiece ==="
python3 -m pip uninstall -y sentencepiece || true
python3 -m pip install --no-binary=:all: sentencepiece -v
# --- Verify Sentencepiece Build ---
python3 -c "import sentencepiece, sys; print('SentencePiece Version:', getattr(sentencepiece,'__version__','unknown'))"
# --- .pc-Files if necessary ---
SPM_PC="$PREFIX/lib/pkgconfig/sentencepiece.pc"
if [ ! -f "$SPM_PC" ]; then
echo "Erstelle fehlende sentencepiece.pc..."
mkdir -p "$(dirname "$SPM_PC")"
cat > "$SPM_PC" <<'EOF'
prefix=/data/data/com.termux/files/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: sentencepiece
Description: SentencePiece library
Version: 0.2.1
Libs: -L${libdir} -lsentencepiece
Cflags: -I${includedir}
EOF
fi
# --- gguf-py Build ---
echo "=== Baue gguf-py ==="
cd ~/BitNet/3rdparty/llama.cpp/gguf-py
python3 -m pip install -v || {
echo "Fehler beim gguf-py Build, versuche Workaround..."
export CMAKE_PREFIX_PATH="$PREFIX/lib/python3.13/site-packages/sentencepiece"
python3 -m pip install -v
}
# --- BitNet Setup ---
echo "=== Setup BitNet Umgebung ==="
cd ~/BitNet
python3 setup_env.py || echo "setup_env.py meldete Warnungen, prüfe Logdatei."
# --- Finish Setup ---
echo "=== Installation ==="
python3 -c "import sentencepiece; print('SentencePiece OK:', sentencepiece.__file__)"
python3 -c "import gguf; print('gguf OK:', gguf.__file__)"
echo "Logdatei gespeichert unter: $LOGFILE"
echo "=== Done ==="