#!/usr/bin/env bash set -euo pipefail ENV_PREFIX="${1:-$PWD/.venv}" PYTHON_BIN="${PYTHON_BIN:-python3}" TORCH_INDEX_URL="${TORCH_INDEX_URL:-https://download.pytorch.org/whl/cu128}" if [[ ! -x "$(command -v "$PYTHON_BIN")" ]]; then echo "Python executable not found: $PYTHON_BIN" >&2 exit 2 fi "$PYTHON_BIN" -m venv "$ENV_PREFIX" "$ENV_PREFIX/bin/python" -m pip install --upgrade pip setuptools wheel "$ENV_PREFIX/bin/python" -m pip install \ --index-url "$TORCH_INDEX_URL" \ torch==2.8.0 torchvision==0.23.0 "$ENV_PREFIX/bin/python" -m pip install -r "$(dirname "$0")/requirements.txt" "$ENV_PREFIX/bin/python" - <<'PY' import cv2 import torch import ultralytics print(f"torch={torch.__version__}") print(f"torchvision CUDA build={torch.version.cuda}") print(f"ultralytics={ultralytics.__version__}") print(f"opencv={cv2.__version__}") print(f"cuda_available={torch.cuda.is_available()}") if torch.cuda.is_available(): for index in range(torch.cuda.device_count()): print(f"gpu[{index}]={torch.cuda.get_device_name(index)}") PY echo "Environment ready. Activate with: source $ENV_PREFIX/bin/activate"