Skip to content

Instantly share code, notes, and snippets.

@Benjamin-Wegener
Last active April 29, 2025 12:12
Show Gist options
  • Save Benjamin-Wegener/e63ac96a316e3f0f3ec9abad16ce8dc5 to your computer and use it in GitHub Desktop.
Save Benjamin-Wegener/e63ac96a316e3f0f3ec9abad16ce8dc5 to your computer and use it in GitHub Desktop.
playstore -> userland -> debian ssh -> bash -c 'wget --no-check-certificate "https://gist.github.com/Benjamin-Wegener/e63ac96a316e3f0f3ec9abad16ce8dc5/raw/ea9055defb5b491a5cd7cdb76bf3e5d88f8515d5/bitnet_android_server.sh" -O bitnet_android_server.sh && chmod +x bitnet_android_server.sh && bash bitnet_android_server.sh'
#!/bin/bash
#
# Script to set up BitNet environment.
#
# This script performs the following steps:
# 1. Updates the system's package list.
# 2. Installs necessary dependencies (lsb-release, wget, software-properties-common, gnupg, git, clang, cmake).
# 3. Adds the LLVM repository and installs LLVM.
# 4. Downloads and installs Miniconda with Python 3.9 based on system architecture.
# 5. Makes the conda binaries executable.
# 6. Initializes conda.
# 7. Reloads the bash configuration.
# 8. Clones the BitNet repository with submodules.
# 9. Changes to the BitNet directory.
# 10. Installs pip into the conda environment.
# 11. Installs the python requirements.
# 12. Downloads the BitNet model.
# 13. Runs the setup_env.py script.
# 14. Runs the inference server.
set -e # Exit immediately if a command exits with a non-zero status, except for apt
# Update package lists
echo "Updating package lists..."
sudo apt update || true # Ignore errors during apt update
# Install dependencies
echo "Installing dependencies..."
sudo apt install lsb-release wget software-properties-common gnupg git clang cmake -y || true # Ignore errors here
# Add LLVM repository and install LLVM
echo "Adding LLVM repository and installing LLVM..."
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" || true # keep going even if this fails.
sudo apt install llvm libllvm13 libclang-13-dev clang-13 -y || true
# Determine system architecture and set Miniconda URL
echo "Determining system architecture..."
if [[ $(uname -m) == "x86_64" ]]; then
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-py39_25.1.1-2-Linux-x86_64.sh"
MINICONDA_ARCH="x86_64"
elif [[ $(uname -m) == "aarch64" ]]; then
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-py39_25.1.1-2-Linux-aarch64.sh"
MINICONDA_ARCH="aarch64"
else
echo "Unsupported architecture: $(uname -m)"
exit 1
fi
# Download and install Miniconda
echo "Downloading Miniconda from $MINICONDA_URL..."
wget $MINICONDA_URL
echo "Installing Miniconda..."
bash Miniconda3-py39_25.1.1-2-Linux-$MINICONDA_ARCH.sh -f -b -p "$HOME/miniconda3"
rm Miniconda3-py39_25.1.1-2-Linux-$MINICONDA_ARCH.sh
# Make conda binaries executable
echo "Making conda binaries executable..."
chmod +x $HOME/miniconda3/bin/*
# Initialize conda
echo "Initializing conda..."
$HOME/miniconda3/bin/conda init bash
# Start a new shell to load conda into PATH
echo "Restarting shell to apply conda environment..."
exec /bin/bash -c "
# Clone BitNet repository
echo \"Cloning BitNet repository...\"
git clone --recurse-submodules https://github.com/Benjamin-Wegener/BitNet.git
# Change to BitNet directory
echo \"Changing to BitNet directory...\"
cd BitNet
# Install pip into the conda environment
echo \"Installing pip...\"
conda install pip -y
# Install python requirements
echo \"Installing python requirements...\"
pip install -r requirements.txt
# Download BitNet model
echo \"Downloading BitNet model...\"
huggingface-cli download microsoft/BitNet-b1.58-2B-4T-gguf --local-dir models/BitNet-b1.58-2B-4T
# Run setup_env.py
echo \"Running setup_env.py...\"
python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s
# Run inference server
echo \"Starting server on localhost 8080...\"
python run_inference_server.py --model models/BitNet-b1.58-2B-4T/ggml-model-f16.bin --prompt \"You are an expert software developer specializing in multiple programming languages...\" --n-predict 4096 --threads 2 --ctx-size 2048 --temperature 0.8 --host 127.0.0.1 --port 8080
echo \"BitNet setup complete!\"
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment