File size: 5,556 Bytes
e841b45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env bash
set -euo pipefail

# Setup script for GPU servers (RTX 5090 / Blackwell sm_120)
# Installs everything INTO THE CURRENTLY ACTIVE environment.
# Usage:
#   source .venv/bin/activate   # hoαΊ·c conda activate <env>
#   bash setup_server.sh

echo "=========================================="
echo "SpecRoute Setup for GPU Server (RTX 5090)"
echo "=========================================="

if command -v nvidia-smi >/dev/null 2>&1; then
  GPU_NAME=$(nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null | head -1 || echo "Unknown")
  echo "[GPU] ${GPU_NAME}"
fi

PY_CMD="python"
PIP_CMD="python -m pip"
PY_VER=$(${PY_CMD} -c "import sys; print('.'.join(map(str, sys.version_info[:2])))")
echo "[Python] ${PY_VER}"

${PIP_CMD} install --upgrade pip wheel

# ── 1. Uninstall conflicting torch (cu124 blocks cu128/cu130) ──────────────
echo ""
echo "[1/5] Uninstalling old CUDA packages..."
${PIP_CMD} uninstall -y \
  torch torchvision torchaudio triton \
  cupy cupy-cuda12x cuda-pathfinder \
  flash-attn \
  2>/dev/null || true

# ── 2. Install PyTorch nightly (sm_120 / RTX 5090 Blackwell support) ─────────
#    RTX 5090 (CC 12.0) needs CUDA 12.8+ β€” only available in nightly builds.
#    Try cu128 first, fallback to cu130.
echo ""
echo "[2/5] Installing PyTorch nightly (sm_120 support)..."
if ! ${PIP_CMD} install --no-cache-dir -q --pre torch torchvision torchaudio \
  --index-url https://download.pytorch.org/whl/nightly/cu128; then
  echo "[Fallback] cu128 unavailable, trying cu130..."
  ${PIP_CMD} install --no-cache-dir -q --pre torch torchvision torchaudio \
    --index-url https://download.pytorch.org/whl/nightly/cu130
fi

TORCH_VER=$(${PY_CMD} -c "import torch; print(torch.__version__)" 2>/dev/null || echo "NONE")
echo "[Check] torch ${TORCH_VER}"

# Check sm_120 support β€” no warning means compatible
if ${PY_CMD} -c "import torch; torch.cuda.get_device_capability()" 2>&1 | grep -q "not compatible"; then
  echo "[ERROR] PyTorch still doesn't support sm_120. Check PyTorch nightly availability."
  echo "        Try: https://pytorch.org/get-started/locally/"
  exit 1
fi

# ── 3. Core Python dependencies (exact pinned versions) ───────────────────────
echo ""
echo "[3/5] Installing pinned Python dependencies..."
${PIP_CMD} install --no-cache-dir -q \
  "numpy==1.26.4" \
  "protobuf==5.29.3" \
  "pyarrow==17.0.0" \
  "fsspec==2024.6.1" \
  "tqdm==4.67.1" \
  "pynvml==11.5.3" \
  "pandas==2.2.2" \
  "scipy==1.14.1" \
  "scikit-learn==1.6.1" \
  "sentencepiece==0.2.0" \
  "loralib==0.1.2" \
  "ipdb==0.13.13" \
  "nltk==3.9.1" \
  "accelerate==0.34.2" \
  "absl-py==2.0.0" \
  2>&1 | grep -v "which is not installed\|which is incompatible\|dependency resolver" || true

# ── 4. transformers + tokenizers (EXACT β€” newer versions have breaking changes) ─
echo ""
echo "[4/5] Installing transformers (exact pinned) + datasets..."
${PIP_CMD} install --no-cache-dir -q \
  "transformers==4.40.2" \
  "tokenizers==0.19.1" \
  "datasets==2.21.0" \
  2>&1 | grep -v "which is not installed\|which is incompatible\|dependency resolver" || true

# ── 5. CuPy (optional β€” compute covariance matrix, not critical for training) ─
#    cupy-cuda12x ships prebuilt; skip if build fails (not blocking).
echo ""
echo "[5/5] Installing CuPy (optional, skip if fails)..."
${PIP_CMD} install --no-cache-dir -q --no-deps cupy-cuda12x \
  2>&1 | grep -v "which is not installed\|which is incompatible\|dependency resolver\|error:" || true

# ── Symlinks ──────────────────────────────────────────────────────────────────
echo ""
echo "[Symlink] Config aliases..."
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${SCRIPT_DIR}"
[ -d configs/gen_script_long_order3_t5_configs ] && \
  [ ! -e configs/Long_Sequence ] && \
  ln -s gen_script_long_order3_t5_configs configs/Long_Sequence
[ -d configs/gen_script_superni_order1_t5_configs ] && \
  [ ! -e configs/SuperNI ] && \
  ln -s gen_script_superni_order1_t5_configs configs/SuperNI

# ── Verify ────────────────────────────────────────────────────────────────────
echo ""
echo "[Verify]"
${PY_CMD} - <<'PY'
import sys
try:
    import torch
    import transformers
    import datasets
    print(f'βœ“ python {sys.version.split()[0]}')
    print(f'βœ“ torch {torch.__version__}')
    print(f'βœ“ numpy {__import__("numpy").__version__}')
    print(f'βœ“ transformers {transformers.__version__}')
    print(f'βœ“ datasets {datasets.__version__}')
    if torch.cuda.is_available():
        cc = torch.cuda.get_device_capability()
        print(f'βœ“ CUDA available, CC {cc[0]}.{cc[1]}')
        print(f'  GPU: {torch.cuda.get_device_name(0)}')
    try:
        import cupy
        print(f'βœ“ cupy {cupy.__version__}')
    except Exception:
        print('⚠ cupy skipped (optional)')
    print('\n[OK] All good!')
except Exception as e:
    print(f'[ERROR] {e}')
    sys.exit(1)
PY

echo ""
echo "=========================================="
echo "[Next] XoΓ‘ --load_best_model_at_end (transformers 4.40.2 validate strict):"
echo "  sed -i 's/--load_best_model_at_end //g' gen_script_long_order3_t5_srt_hard.sh"
echo "=========================================="