Files
iomgaa e72d07aced 层1: ars_opd 改为 editable 安装,修复脚本/调试器 import 失败
- pyproject.toml: 最小打包配置(依赖仍统一走 requirements*.txt)
- .vscode/launch.json: 调试当前文件 + teacher 生成两个配置,cwd 锚定仓库根
- setup_remote.sh 与 CLAUDE.md 常用命令同步 pip install -e

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-18 08:06:40 -04:00

60 lines
2.6 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 远程机 gpu-a800-060 环境搭建(幂等,可重复执行)。
# 用法:bash scripts/setup_remote.sh
# 硬约束:根分区仅剩 12G —— 环境、缓存、临时目录一律压到 /data/zym 下。
set -euo pipefail
DATA_ROOT=/data/zym
ENV_PATH=$DATA_ROOT/envs/ars-opd
REPO_DIR=$DATA_ROOT/ars-opd-rebuild
# ---- 0. 所有会写盘的路径全部改道 /data(防根分区被写爆)----
export HF_ENDPOINT=https://hf-mirror.com # huggingface.co 被墙,走镜像
export HF_HOME=$DATA_ROOT/hf_cache
export CONDA_PKGS_DIRS=$DATA_ROOT/conda_pkgs # conda 包缓存默认在根分区
export PIP_CACHE_DIR=$DATA_ROOT/pip_cache # pip 缓存默认在根分区
export TMPDIR=$DATA_ROOT/tmp # 大 wheel 解压临时目录
mkdir -p "$DATA_ROOT"/{envs,hf_cache,conda_pkgs,pip_cache,tmp}
# 清理上次中断可能残留的 pip 临时目录(含曾被 conda run 吞掉 TMPDIR 而落在 /tmp 的)
rm -rf "$DATA_ROOT"/tmp/pip-* /tmp/pip-unpack-* 2>/dev/null || true
# ---- 1. conda 环境(建在 /data,不建在 ~----
if [ ! -d "$ENV_PATH" ]; then
conda create -p "$ENV_PATH" python=3.11 -y
fi
# ---- 2. 代码(远程只读:clone 走 HTTPS 匿名,更新只 git pull----
if [ ! -d "$REPO_DIR" ]; then
git clone https://gitea.iomgaa.online/iomgaa/ars-opd-rebuild.git "$REPO_DIR"
else
git -C "$REPO_DIR" pull
fi
# ---- 3. 依赖 ----
# 直接调环境内 pip:conda run 会整体缓冲子命令输出(违反"日志实时可查"规矩),弃用
"$ENV_PATH/bin/pip" install -r "$REPO_DIR/requirements.txt" -r "$REPO_DIR/requirements-remote.txt"
# ars_opd 以 editable 方式注册进环境:脚本从任意目录都能 import,不依赖 cwd
"$ENV_PATH/bin/pip" install -e "$REPO_DIR" --no-build-isolation --no-deps
# ---- 4. 环境变量持久化(写入 ~/.bashrc,幂等)----
if ! grep -q "ars-opd-rebuild env" ~/.bashrc; then
cat >> ~/.bashrc <<'EOF'
# --- ars-opd-rebuild env ---
export HF_ENDPOINT=https://hf-mirror.com
export HF_HOME=/data/zym/hf_cache
export CONDA_PKGS_DIRS=/data/zym/conda_pkgs
export PIP_CACHE_DIR=/data/zym/pip_cache
alias opd='conda activate /data/zym/envs/ars-opd && cd /data/zym/ars-opd-rebuild'
EOF
fi
# ---- 5. 验证 ----
echo "=== 验证 torch/CUDA ==="
"$ENV_PATH/bin/python" -c "import torch; print('torch', torch.__version__, '| cuda可用:', torch.cuda.is_available(), '| 卡数:', torch.cuda.device_count())"
echo "=== 验证单元测试 ==="
"$ENV_PATH/bin/python" -m pytest "$REPO_DIR/tests" -q
echo "=== 磁盘检查(根分区不应有明显增长)==="
df -h / /data | tail -2
echo "全部完成。日常使用:输入 opd 进入环境与目录。"