- v3-P2-1: _npu_test/_onnx_validate 按 normalize_mode 分支(fixed_range 免 stats, HailoPredictor 透传模式,torch 参考同口径反归一化) - v3-P2-2: export_deploy/export_onnx 一致性 diff 超 1e-4 即 sys.exit(P2-f 闭环) - v3-P2-3: run_loop overrun 告警节流(第1次+每100次),降 hz 建议仅 >10% 输出 - P2-a1: default_column_weights 扩展列(action_dim>18)默认 1.0 - P2-c: 补 predictor 异常清理路径测试(异常传播 + finally 落盘) - P2-d/P2-e: Resize 口径与 resume scheduler T_max 语义文档化 - R2-4: _set.sh 安装后断言 CPU 版 torch,误装 CUDA 即拦截 测试: pybot 89 passed (+1)、actpred 148 passed/18 skipped
48 lines
1.9 KiB
Bash
Executable File
48 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
||
cd "$(dirname "$0")" || exit
|
||
python3 -m venv venv
|
||
source venv/bin/activate
|
||
|
||
# CPU-only PyTorch (no CUDA dependency)
|
||
# 如需 GPU 支持,注释掉下面一行并改用:pip install torch torchvision
|
||
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
|
||
|
||
# Remaining deps from Tsinghua mirror
|
||
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||
|
||
# ONNX 导出依赖(torch>=2.12 的 torch.onnx.export 走 dynamo 路径,onnxscript 为硬依赖)
|
||
pip install onnxscript onnxruntime -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||
|
||
pip check
|
||
mkdir -p checkpoints data
|
||
|
||
# R2-4 防呆:确认装到的是 CPU 版 torch——requirements.txt 含 torch,
|
||
# 若被镜像源重装成 CUDA 版(无 GPU 部署会被 CUDA 依赖拖垮)在此拦截
|
||
python3 -c "
|
||
import torch
|
||
assert torch.version.cuda is None, (
|
||
f'检测到 CUDA 版 torch({torch.__version__}),'
|
||
'请用 _set.sh 的 CPU 源重装: pip install torch torchvision '
|
||
'--index-url https://download.pytorch.org/whl/cpu --force-reinstall')
|
||
print('torch CPU build OK:', torch.__version__)
|
||
"
|
||
|
||
# Pre-download MobileNetV2 weights for offline fine-tuning (optional, skip if backbone=simple)
|
||
python3 -c "
|
||
import torch, sys, os
|
||
hub_dir = torch.hub.get_dir()
|
||
cache = os.path.join(hub_dir, 'checkpoints', 'mobilenet_v2-b0353104.pth')
|
||
if os.path.exists(cache):
|
||
print(f'MobileNetV2 weights already cached: {cache}')
|
||
sys.exit(0)
|
||
url = 'https://download.pytorch.org/models/mobilenet_v2-b0353104.pth'
|
||
try:
|
||
torch.hub.load_state_dict_from_url(url, model_dir=os.path.join(hub_dir, 'checkpoints'))
|
||
print('MobileNetV2 weights cached to: ' + cache)
|
||
except Exception as e:
|
||
print(f'WARNING: MobileNetV2 weights download failed: {e}')
|
||
print(' backbone=simple still works; for mobilenet, manually download from:')
|
||
print(f' {url}')
|
||
print(f' and place at: {cache}')
|
||
" || echo "WARNING: MobileNetV2 weight pre-download skipped"
|