Last active
November 29, 2024 12:59
-
-
Save CultriX-Github/b653a2ead58122c6bab90751070eaf6d to your computer and use it in GitHub Desktop.
Llama-Factory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Functions | |
install_basic_packages() { | |
echo "Installing basic packages..." | |
apt update -y && apt install -y screen nano git git-lfs speedometer htop libaio-dev || { | |
echo "Failed to install basic packages" >&2 | |
exit 1 | |
} | |
} | |
install_croc() { | |
echo "Installing croc..." | |
curl -fsSL https://getcroc.schollz.com | bash || { | |
echo "Failed to install croc" >&2 | |
exit 1 | |
} | |
} | |
install_python_tools() { | |
echo "Installing Python tools..." | |
pip install --upgrade pip || { | |
echo "Failed to upgrade pip" >&2 | |
exit 1 | |
} | |
pip install wandb huggingface_hub[hf-transfer] || { | |
echo "Failed to install Python tools" >&2 | |
exit 1 | |
} | |
} | |
login_tools() { | |
echo "Logging into WandB and Huggingface..." | |
if [ -z "$HF_TOKEN" ]; then | |
echo "Environment variable HF_TOKEN is not set. Please set it and try again." >&2 | |
exit 1 | |
fi | |
huggingface-cli login --token "$HF_TOKEN" || { | |
echo "Huggingface login failed" >&2 | |
exit 1 | |
} | |
if [ -z "$WANDB_API_KEY" ]; then | |
echo "Environment variable WANDB_API_KEY is not set. Please set it and try again." >&2 | |
exit 1 | |
fi | |
wandb login "$WANDB_API_KEY" || { | |
echo "WandB login failed" >&2 | |
exit 1 | |
} | |
} | |
clone_llama_factory() { | |
echo "Cloning LLaMA-Factory..." | |
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git || { | |
echo "Failed to clone LLaMA-Factory" >&2 | |
exit 1 | |
} | |
cd LLaMA-Factory || exit 1 | |
pip install -e ".[torch,metrics,deepspeed,qwen,vllm,bitsandbytes]" || { | |
echo "Failed to install LLaMA-Factory dependencies" >&2 | |
exit 1 | |
} | |
pip install flash-attn || { | |
echo "Failed to install flash-attn" >&2 | |
exit 1 | |
} | |
} | |
start_webui() { | |
echo "Starting web UI..." | |
screen -S webui -m bash -c '/bin/bash' || { | |
echo "Failed to start web UI" >&2 | |
exit 1 | |
} | |
} | |
# Main Script Execution | |
main() { | |
install_basic_packages | |
install_croc | |
install_python_tools | |
login_tools | |
clone_llama_factory | |
start_webui | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment