chore: Up
This commit is contained in:
90
setup.sh
90
setup.sh
@@ -1,41 +1,79 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -eu
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
check_command() {
|
# constants
|
||||||
if [ $? -ne 0 ]; then
|
WORKSPACE_DIR="/workspace"
|
||||||
echo "Error: $1 failed"
|
REPO_URL="https://git.hye.su/mira/unsloth-train-scripts.git"
|
||||||
|
INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/unslothai/unsloth/main/unsloth/_auto_install.py"
|
||||||
|
DATASET_URL="https://drive.google.com/file/d/1mqhq69dsSOK7ep7trTjRd3FMagTFTrzF/view?usp=sharing"
|
||||||
|
|
||||||
|
error_exit() {
|
||||||
|
echo "Error: $1" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
run_command() {
|
||||||
|
if ! "$@"; then
|
||||||
|
error_exit "Command failed: $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cd /workspace || {
|
check_root() {
|
||||||
echo "Error: Cannot change to /workspace directory"
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
exit 1
|
error_exit "This script must be run as root"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Cloning unsloth-train-scripts repository..."
|
setup_workspace() {
|
||||||
git clone https://git.hye.su/mira/unsloth-train-scripts.git
|
cd "$WORKSPACE_DIR" || error_exit "Cannot change to $WORKSPACE_DIR directory"
|
||||||
check_command "Git clone"
|
}
|
||||||
|
|
||||||
echo "Downloading and running unsloth auto-install script..."
|
install_system_packages() {
|
||||||
INSTALL_CMD=$(wget -qO- https://raw.githubusercontent.com/unslothai/unsloth/main/unsloth/_auto_install.py | python -)
|
echo "Installing system packages..."
|
||||||
check_command "Auto-install script"
|
run_command apt-get update
|
||||||
|
run_command apt-get install -y cmake tmux vim
|
||||||
|
}
|
||||||
|
|
||||||
echo "Executing installation command..."
|
clone_repository() {
|
||||||
eval "$INSTALL_CMD"
|
echo "Cloning unsloth-train-scripts repository..."
|
||||||
check_command "Installation command"
|
run_command git clone "$REPO_URL"
|
||||||
|
}
|
||||||
|
|
||||||
echo "Installing additional dependencies..."
|
install_unsloth() {
|
||||||
pip install gdown wandb
|
echo "Downloading and running unsloth auto-install script..."
|
||||||
check_command "pip install"
|
INSTALL_CMD=$(wget -qO- "$INSTALL_SCRIPT_URL" | python -) || error_exit "Failed to get install command"
|
||||||
|
[ -n "$INSTALL_CMD" ] || error_exit "Empty install command received"
|
||||||
|
run_command eval "$INSTALL_CMD"
|
||||||
|
}
|
||||||
|
|
||||||
echo "Downloading dataset"
|
install_python_deps() {
|
||||||
gdown --fuzzy 'https://drive.google.com/file/d/1mqhq69dsSOK7ep7trTjRd3FMagTFTrzF/view?usp=sharing'
|
echo "Installing additional dependencies..."
|
||||||
check_command "gdown"
|
run_command pip install gdown wandb
|
||||||
|
}
|
||||||
|
|
||||||
echo "Enter your Weights & Biases API key when prompted"
|
download_dataset() {
|
||||||
wandb login
|
echo "Downloading dataset..."
|
||||||
check_command "wandb login"
|
run_command gdown --fuzzy "$DATASET_URL"
|
||||||
|
}
|
||||||
|
|
||||||
echo "Setup completed successfully."
|
setup_wandb() {
|
||||||
|
echo "Enter your Weights & Biases API key when prompted"
|
||||||
|
run_command wandb login
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main execution
|
||||||
|
main() {
|
||||||
|
check_root
|
||||||
|
setup_workspace
|
||||||
|
install_system_packages
|
||||||
|
clone_repository
|
||||||
|
install_unsloth
|
||||||
|
install_python_deps
|
||||||
|
download_dataset
|
||||||
|
setup_wandb
|
||||||
|
echo "Setup completed successfully."
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
|
|||||||
Reference in New Issue
Block a user