36 lines
1.6 KiB
Bash
Executable File
36 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# 幂等预取官方权重到 weights_cache/ (供 Dockerfile COPY, 镜像内不再下载)。
|
|
# 三层来源: 本地缓存命中 -> jfs 拷贝 -> 代理在线拉取 (GCS 公开桶)。
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
CACHE="weights_cache/openpi_weights"
|
|
JFS="${OPENPI_WEIGHTS_JFS:-/mnt/data/chao01.wu/OpenPI_Dev/.local_dev/openpi_weights}"
|
|
|
|
ok_params=0
|
|
ok_tok=0
|
|
[ -d "$CACHE/pi05_base/params" ] && [ -n "$(ls -A "$CACHE/pi05_base/params" 2>/dev/null)" ] && ok_params=1
|
|
[ -s "$CACHE/big_vision/paligemma_tokenizer.model" ] && ok_tok=1
|
|
|
|
if [ "$ok_params" -eq 1 ] && [ "$ok_tok" -eq 1 ]; then
|
|
echo "[fetch_weights] cache OK: $CACHE"
|
|
exit 0
|
|
fi
|
|
|
|
mkdir -p "$CACHE/pi05_base" "$CACHE/big_vision"
|
|
|
|
if [ -d "$JFS/pi05_base/params" ] && [ -s "$JFS/big_vision/paligemma_tokenizer.model" ]; then
|
|
echo "[fetch_weights] copy from jfs: $JFS"
|
|
[ "$ok_params" -eq 1 ] || cp -a "$JFS/pi05_base/params" "$CACHE/pi05_base/params"
|
|
[ "$ok_tok" -eq 1 ] || cp -a "$JFS/big_vision/paligemma_tokenizer.model" "$CACHE/big_vision/"
|
|
echo "[fetch_weights] done (from jfs)"
|
|
exit 0
|
|
fi
|
|
|
|
echo "[fetch_weights] jfs cache unavailable, fetching online via proxy"
|
|
export http_proxy="${http_proxy:-http://192.168.16.68:18000}"
|
|
export https_proxy="${https_proxy:-http://192.168.16.68:18000}"
|
|
[ "$ok_params" -eq 1 ] || python3 scripts/fetch_gcs_public.py openpi-assets checkpoints/pi05_base/params "$CACHE/pi05_base/params" --required
|
|
[ "$ok_tok" -eq 1 ] || python3 scripts/fetch_gcs_public.py big_vision paligemma_tokenizer.model "$CACHE/big_vision" --required
|
|
echo "[fetch_weights] done (online)"
|