gregjanik commited on
Commit
06271d9
·
verified ·
1 Parent(s): 6dba186

Upload bootstrap.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. bootstrap.sh +65 -0
bootstrap.sh ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # ============================================================================
5
+ # bootstrap.sh — Zero-image entrypoint for RunPod Instant Clusters.
6
+ #
7
+ # This script runs inside the stock runpod/pytorch base image (no custom
8
+ # Docker build). It:
9
+ # 1. Fixes the Python 3.10 → 3.12 symlink mismatch
10
+ # 2. Exports environment variables matching Dockerfile.slim
11
+ # 3. Configures SSH for multi-node communication
12
+ # 4. Installs vim (apt, one-time)
13
+ # 5. Creates workspace directories
14
+ # 6. Hands off to slim-entrypoint.sh (pip deps + app launch)
15
+ #
16
+ # The HF download of f13rnd/training-runtime into /opt/f13/ is done by the
17
+ # RunPod CMD *before* this script runs, so all files are already in place.
18
+ #
19
+ # RunPod template CMD:
20
+ # bash -c "pip install -q huggingface_hub && \
21
+ # hf download f13rnd/training-runtime --repo-type dataset \
22
+ # --local-dir /opt/f13 ${HF_TOKEN:+--token $HF_TOKEN} && \
23
+ # chmod +x /opt/f13/*.sh /opt/f13/scripts/*.sh && \
24
+ # exec /opt/f13/bootstrap.sh"
25
+ # ============================================================================
26
+
27
+ echo "[bootstrap] Starting zero-image bootstrap..."
28
+
29
+ # --- Python 3.12 symlink fix ---
30
+ # The runpod/pytorch base ships python3 -> 3.10 but pip/torch target 3.12.
31
+ if [ -x /usr/bin/python3.12 ]; then
32
+ ln -sf /usr/bin/python3.12 /usr/bin/python3
33
+ ln -sf /usr/bin/python3.12 /usr/bin/python
34
+ echo "[bootstrap] python3 -> python3.12"
35
+ fi
36
+
37
+ # --- Environment variables (match Dockerfile.slim) ---
38
+ export DEBIAN_FRONTEND=noninteractive
39
+ export PYTHONUNBUFFERED=1
40
+ export PYTORCH_ALLOC_CONF="${PYTORCH_ALLOC_CONF:-expandable_segments:True}"
41
+ export HF_HOME="${HF_HOME:-/workspace/hf-cache}"
42
+ export MODELSCOPE_CACHE="${MODELSCOPE_CACHE:-/workspace/ms-cache}"
43
+ export HF_HUB_DISABLE_PROGRESS_BARS="${HF_HUB_DISABLE_PROGRESS_BARS:-0}"
44
+ export HF_HUB_VERBOSITY="${HF_HUB_VERBOSITY:-info}"
45
+ export TRANSFORMERS_VERBOSITY="${TRANSFORMERS_VERBOSITY:-info}"
46
+
47
+ # --- apt packages (idempotent) ---
48
+ if ! command -v vim &>/dev/null; then
49
+ apt-get update -qq && apt-get install -y --no-install-recommends vim \
50
+ && rm -rf /var/lib/apt/lists/*
51
+ echo "[bootstrap] vim installed"
52
+ fi
53
+
54
+ # --- SSH setup ---
55
+ mkdir -p /var/run/sshd
56
+ if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
57
+ ssh-keygen -A
58
+ fi
59
+ sed -i 's/#*PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
60
+
61
+ # --- Workspace directories ---
62
+ mkdir -p /workspace/data /workspace/output /workspace/config
63
+
64
+ echo "[bootstrap] Bootstrap complete, handing off to slim-entrypoint.sh"
65
+ exec /opt/f13/slim-entrypoint.sh "$@"