Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·66 lines (58 loc) · 2.23 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·66 lines (58 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
# Environment setup for LoRA fine-tuning with Unsloth
# Validated for RTX 5070 Laptop (Blackwell, sm_120) with CUDA 12.8+ and PyTorch 2.11
set -e
GPU=$(nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null | head -1 || echo "not detected")
DRIVER_CUDA=$(nvidia-smi | grep -oP "CUDA Version: \K[\d\.]+" || echo "unknown")
echo "=== LoRA fine-tuning setup ==="
echo "GPU: $GPU"
echo "Driver CUDA: $DRIVER_CUDA"
echo ""
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip --quiet
# cu128 wheels support Blackwell (sm_120) and require CUDA driver >= 12.8
# cu126 wheels top out at sm_90 — will NOT use the RTX 5000 GPU for training
echo "[1/4] Installing PyTorch 2.11 with CUDA 12.8 support (Blackwell)..."
pip install \
"torch==2.11.0+cu128" \
"torchvision" \
"torchaudio" \
--index-url https://download.pytorch.org/whl/cu128 \
--quiet
echo "[2/4] Installing Unsloth..."
# Install from PyPI — this version is validated against PyTorch 2.11
# The unsloth-zoo metadata constraint (torch<2.11) is outdated and safe to ignore
pip install unsloth --quiet
echo "[3/4] Installing training and data libraries..."
pip install trl peft accelerate bitsandbytes datasets transformers --quiet
echo "[4/4] Installing utilities..."
pip install pyyaml wandb --quiet
echo ""
echo "=== Verifying installation ==="
python - <<'EOF'
from unsloth import FastLanguageModel
from trl import SFTTrainer, SFTConfig
import torch
assert torch.cuda.is_available(), "CUDA not available"
print(f" torch: {torch.__version__}")
print(f" GPU: {torch.cuda.get_device_name(0)}")
print(f" VRAM: {torch.cuda.get_device_properties(0).total_memory / 1024**3:.1f} GB")
print(" unsloth: OK")
print(" trl: OK")
EOF
echo ""
echo "=== Setup complete ==="
echo ""
echo "Activate the environment:"
echo " source .venv/bin/activate"
echo ""
echo "Workflow:"
echo " make prepare # process raw data into train/eval JSONL"
echo " make train # run fine-tuning"
echo " make eval # compare base vs fine-tuned"
echo " make export # export to GGUF for Ollama"
echo ""
echo "To enable Ollama export, install llama.cpp:"
echo " git clone https://github.com/ggerganov/llama.cpp"
echo " pip install -r llama.cpp/requirements.txt"