69 lines
2.0 KiB
Bash
Executable File
69 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Deploy LoRA training repo (clone + prepare dataset).
|
|
# Training is run manually on the GPU server.
|
|
#
|
|
# Usage:
|
|
# bash deploy-and-train.sh
|
|
#
|
|
# This will:
|
|
# 1. Clone/update the repo to /opt/loras/agenx-lora-training
|
|
# 2. Print instructions for downloading dataset and training
|
|
#
|
|
|
|
set -euo pipefail
|
|
|
|
# Configuration
|
|
REPO_URL="${LORA_DEPLOY_REPO_URL:-https://gitea.cyaren.com/cmedina/agenx-lora-training.git}"
|
|
REPO_DIR="${LORA_DEPLOY_REPO_DIR:-/opt/loras/agenx-lora-training}"
|
|
BRANCH="${LORA_DEPLOY_BRANCH:-main}"
|
|
|
|
RUN_USER="${SUDO_USER:-$(id -un)}"
|
|
RUN_GROUP="$(id -gn "${RUN_USER}" 2>/dev/null || id -gn)"
|
|
REPO_PARENT="$(dirname "${REPO_DIR}")"
|
|
|
|
echo "=== LoRA Training Deploy ==="
|
|
echo "Repo: ${REPO_URL}"
|
|
echo "Dir: ${REPO_DIR}"
|
|
echo "Branch: ${BRANCH}"
|
|
echo ""
|
|
|
|
# Create parent directory if needed
|
|
if [ ! -d "${REPO_PARENT}" ]; then
|
|
echo "Creating ${REPO_PARENT}..."
|
|
sudo install -d -m 0755 -o "${RUN_USER}" -g "${RUN_GROUP}" "${REPO_PARENT}"
|
|
fi
|
|
|
|
# Clone or update repo
|
|
if [ ! -d "${REPO_DIR}/.git" ]; then
|
|
echo "Cloning repository..."
|
|
git clone --branch "${BRANCH}" "${REPO_URL}" "${REPO_DIR}"
|
|
else
|
|
echo "Repository exists, pulling latest..."
|
|
cd "${REPO_DIR}"
|
|
git fetch origin "${BRANCH}"
|
|
git checkout "${BRANCH}"
|
|
git pull --ff-only origin "${BRANCH}"
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== Repository ready ==="
|
|
echo "Location: ${REPO_DIR}"
|
|
echo ""
|
|
echo "=== Next Steps ==="
|
|
echo ""
|
|
echo "1. Download dataset (8.77 MB):"
|
|
echo " cd ${REPO_DIR}"
|
|
echo " curl -O https://gitea.cyaren.com/cmedina/agenx-lora-training/raw/branch/main/dataset/combined_20k.jsonl"
|
|
echo ""
|
|
echo "2. Setup Python + GPU drivers on your training server"
|
|
echo ""
|
|
echo "3. Prepare dataset:"
|
|
echo " python3 training/scripts/prepare_dataset.py --input dataset/combined_20k.jsonl --output training/data"
|
|
echo ""
|
|
echo "4. Train LoRA (on GPU server):"
|
|
echo " python3 training/scripts/train.py --config training/configs/llama2-7b-lora.yaml"
|
|
echo ""
|
|
echo "=== To train now (if on GPU server) ==="
|
|
echo " bash ${REPO_DIR}/train-on-this-server.sh"
|
|
echo ""
|