Files
FishServer/packaging/bootstrap_fishserver.sh

77 lines
2.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# 创建 / 更新 fishserverconda 只装 Python/numpy/opencv
# 全部 pip 使用 env 内解释器 -m pip避免 conda activate 在脚本里失效时装到 base(cp312)。
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
YAML="$ROOT/packaging/conda-fishserver.yaml"
CONDA_BASE="$(conda info --base)"
ENV_DIR="$CONDA_BASE/envs/fishserver"
PY="$ENV_DIR/bin/python"
if [[ ! -f "$YAML" ]]; then
echo "Missing $YAML" >&2
exit 1
fi
echo "Using conda base: $CONDA_BASE"
echo "Fishserver prefix will be: $ENV_DIR"
if [[ -x "$PY" ]]; then
echo "Updating existing conda env: fishserver (conda packages only)"
conda env update -n fishserver -f "$YAML"
else
echo "Creating conda env: fishserver"
conda env create -f "$YAML"
fi
if [[ ! -x "$PY" ]]; then
echo "ERROR: Expected interpreter missing: $PY" >&2
echo "Check: conda env list | grep fishserver" >&2
echo "If you use multiple installs (miniconda + miniforge), run this script with the SAME conda as in your shell: $(command -v conda)" >&2
exit 1
fi
echo "Using interpreter: $PY ($("$PY" --version 2>&1))"
# 必须用 --index-url 指向 cu124若主索引仍是 pypipip 会解析到最新 +cu130 轮子,与 CUDA 12.4 / 现有驱动不匹配。
TORCH_INDEX="${TORCH_INDEX:-https://download.pytorch.org/whl/cu124}"
export PIP_DEFAULT_TIMEOUT="${PIP_DEFAULT_TIMEOUT:-120}"
echo "Installing PyTorch (CUDA 12.x wheels from $TORCH_INDEX only) ..."
"$PY" -m pip install --upgrade pip
"$PY" -m pip uninstall -y torch torchvision 2>/dev/null || true
PIP_CONFIG_FILE=/dev/null PIP_EXTRA_INDEX_URL="" \
"$PY" -m pip install --no-cache-dir torch torchvision --index-url "$TORCH_INDEX"
export PIP_INDEX_URL="${PIP_INDEX_URL:-https://pypi.org/simple}"
unset PIP_EXTRA_INDEX_URL
echo "Installing remaining pip deps ..."
"$PY" -m pip install \
"fastapi>=0.115.0" \
"uvicorn[standard]>=0.32.0" \
"pydantic-settings>=2.6.0" \
ultralytics \
open3d \
segment-anything \
fvcore \
iopath \
pytorchvideo \
av
"$PY" -c "import torch; print('torch', torch.__version__, 'cuda', torch.cuda.is_available())"
echo ""
echo "Done."
echo " Conda base was: $CONDA_BASE"
echo " Activate THIS same stack in your shell:"
echo " source \"$CONDA_BASE/etc/profile.d/conda.sh\""
echo " conda activate fishserver"
echo " Or run Python directly:"
echo " $PY -c \"import sys; print(sys.executable)\""
echo ""
2026-04-10 10:30:01 +08:00
echo " Then: PORT=8001 bash scripts/start_fresh.sh"
echo " (SVO) ZED SDK + pip install pyzed inside fishserver"