Upload slim-entrypoint.sh with huggingface_hub
Browse files- slim-entrypoint.sh +92 -0
slim-entrypoint.sh
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
|
| 4 |
+
DEPS_MARKER="/workspace/.f13-deps-installed"
|
| 5 |
+
WHEEL_DIR="/workspace/.f13-wheels"
|
| 6 |
+
HF_WHEEL_REPO="f13rnd/custom-wheels"
|
| 7 |
+
|
| 8 |
+
hf_download() {
|
| 9 |
+
hf download "$@" ${HF_TOKEN:+--token "${HF_TOKEN}"}
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
hf_upload() {
|
| 13 |
+
hf upload "$@" ${HF_TOKEN:+--token "${HF_TOKEN}"}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
install_from_hf_or_build() {
|
| 17 |
+
local pkg_name="$1" pip_spec="$2"
|
| 18 |
+
local glob="${pkg_name}-*.whl"
|
| 19 |
+
mkdir -p "${WHEEL_DIR}"
|
| 20 |
+
|
| 21 |
+
local whl
|
| 22 |
+
whl=$(ls "${WHEEL_DIR}"/${glob} 2>/dev/null | head -1)
|
| 23 |
+
if [ -n "${whl}" ]; then
|
| 24 |
+
echo "[slim] Installing ${pkg_name} from cached wheel"
|
| 25 |
+
pip install --no-cache-dir "${whl}" && return 0
|
| 26 |
+
fi
|
| 27 |
+
|
| 28 |
+
echo "[slim] Trying to download ${pkg_name} wheel from HF..."
|
| 29 |
+
hf_download "${HF_WHEEL_REPO}" \
|
| 30 |
+
--repo-type dataset \
|
| 31 |
+
--include "${glob}" \
|
| 32 |
+
--local-dir "${WHEEL_DIR}" 2>/dev/null || true
|
| 33 |
+
|
| 34 |
+
whl=$(ls "${WHEEL_DIR}"/${glob} 2>/dev/null | head -1)
|
| 35 |
+
if [ -n "${whl}" ]; then
|
| 36 |
+
echo "[slim] Installing ${pkg_name} from HF wheel"
|
| 37 |
+
pip install --no-cache-dir "${whl}" && return 0
|
| 38 |
+
fi
|
| 39 |
+
|
| 40 |
+
echo "[slim] No prebuilt wheel found — building ${pkg_name} from source..."
|
| 41 |
+
TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-9.0}" \
|
| 42 |
+
MAX_JOBS="${MAX_JOBS:-2}" \
|
| 43 |
+
NVCC_THREADS="${NVCC_THREADS:-1}" \
|
| 44 |
+
pip wheel ${pip_spec} --no-build-isolation --no-deps --wheel-dir "${WHEEL_DIR}"
|
| 45 |
+
whl=$(ls "${WHEEL_DIR}"/${glob} 2>/dev/null | head -1)
|
| 46 |
+
pip install --no-cache-dir "${whl}"
|
| 47 |
+
|
| 48 |
+
echo "[slim] Uploading ${pkg_name} wheel to HF for future use..."
|
| 49 |
+
hf_upload "${HF_WHEEL_REPO}" \
|
| 50 |
+
"${whl}" "$(basename "${whl}")" \
|
| 51 |
+
--repo-type dataset 2>/dev/null \
|
| 52 |
+
|| echo "[slim] WARN: failed to upload ${pkg_name} wheel to HF (non-fatal)"
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
if [ -f "${DEPS_MARKER}" ]; then
|
| 56 |
+
echo "[slim] Deps already installed"
|
| 57 |
+
else
|
| 58 |
+
echo "[slim] Installing training deps (first boot)..."
|
| 59 |
+
|
| 60 |
+
pip install --no-cache-dir \
|
| 61 |
+
"ms-swift>=4.0.2" \
|
| 62 |
+
accelerate \
|
| 63 |
+
deepspeed \
|
| 64 |
+
"qwen_vl_utils>=0.0.14" \
|
| 65 |
+
decord \
|
| 66 |
+
torchvision \
|
| 67 |
+
fastapi \
|
| 68 |
+
"uvicorn[standard]" \
|
| 69 |
+
python-multipart \
|
| 70 |
+
wandb \
|
| 71 |
+
huggingface_hub
|
| 72 |
+
|
| 73 |
+
pip install --no-cache-dir "transformers>=5.3.0,<5.4.0"
|
| 74 |
+
pip install --no-cache-dir --no-deps "datasets>=4.7.0"
|
| 75 |
+
|
| 76 |
+
install_from_hf_or_build "flash_attn" "flash-attn" \
|
| 77 |
+
|| echo "[slim] WARN: flash-attn install failed"
|
| 78 |
+
|
| 79 |
+
install_from_hf_or_build "causal_conv1d" "causal-conv1d" \
|
| 80 |
+
|| echo "[slim] WARN: causal-conv1d install failed"
|
| 81 |
+
|
| 82 |
+
pip install --no-cache-dir \
|
| 83 |
+
"flash-linear-attention @ git+https://github.com/fla-org/flash-linear-attention" \
|
| 84 |
+
|| echo "[slim] WARN: flash-linear-attention install failed"
|
| 85 |
+
|
| 86 |
+
pip install --no-cache-dir "dlrover[torch]" || true
|
| 87 |
+
|
| 88 |
+
touch "${DEPS_MARKER}"
|
| 89 |
+
echo "[slim] Deps installed"
|
| 90 |
+
fi
|
| 91 |
+
|
| 92 |
+
exec /opt/f13/scripts/entrypoint.sh "$@"
|