File size: 3,736 Bytes
0185029
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
ORARL_ROOT="$(cd -- "${SCRIPT_DIR}/.." && pwd)"

ENV_NAME="${ORARL_CONDA_ENV:-orarl}"
PYTORCH_INDEX="https://download.pytorch.org/whl/cu129"
EVALUATION_ONLY=0

usage() {
  cat <<'EOF'
Usage: bash scripts/create_conda_env.sh [options]

Create the pinned OraRL CUDA 12.9 environment. This checkout ships both the
training runtime and the evaluators, so no external runtime is required. Use
--evaluation-only to skip the training-side environment validation.

Options:
  --name ENV_NAME       Conda environment name (default: orarl).
  --evaluation-only     Validate the environment for evaluation only.
EOF
}

while [[ $# -gt 0 ]]; do
  case "$1" in
    --name)
      if [[ $# -lt 2 || -z "$2" ]]; then
        echo "ERROR: --name requires a non-empty environment name." >&2
        exit 2
      fi
      ENV_NAME="$2"
      shift 2
      ;;
    --evaluation-only)
      EVALUATION_ONLY=1
      shift
      ;;
    -h|--help)
      usage
      exit 0
      ;;
    *)
      echo "ERROR: unknown argument: $1" >&2
      usage >&2
      exit 2
      ;;
  esac
done

if ! command -v conda >/dev/null 2>&1; then
  echo "ERROR: conda is not available in PATH." >&2
  exit 1
fi

if [[ ! -d "${ORARL_ROOT}/verl" ]]; then
  echo "ERROR: the bundled training runtime is missing at ${ORARL_ROOT}/verl." >&2
  echo "Clone the full repository instead of copying individual directories." >&2
  exit 1
fi

if command -v nvidia-smi >/dev/null 2>&1; then
  echo "Detected cluster GPU(s):"
  nvidia-smi --query-gpu=name,driver_version --format=csv,noheader || true
  echo "CUDA 12.9 GA officially requires Linux driver 575.51.03 or newer."
else
  echo "WARNING: nvidia-smi is unavailable; run the GPU check on an allocated H20 node." >&2
fi

if conda run -n "${ENV_NAME}" python -c "pass" >/dev/null 2>&1; then
  echo "ERROR: conda environment '${ENV_NAME}' already exists." >&2
  echo "Choose another name with --name or remove/update it explicitly." >&2
  exit 1
fi

conda env create \
  --name "${ENV_NAME}" \
  --file "${ORARL_ROOT}/environment.yml"

run_in_env() {
  conda run --no-capture-output -n "${ENV_NAME}" "$@"
}

run_in_env python -m pip install --upgrade \
  "pip==26.0.1" \
  "setuptools==82.0.1" \
  "wheel==0.46.3"

# Install the CUDA build explicitly. Generic PyPI resolves PyTorch 2.10 to the
# CUDA 12.8 wheel, which is not the stack validated with vLLM 0.19.1 here.
run_in_env python -m pip install \
  "torch==2.10.0+cu129" \
  "torchvision==0.25.0+cu129" \
  "torchaudio==2.10.0+cu129" \
  --index-url "${PYTORCH_INDEX}"

# PyTorch must be importable before building FlashAttention.
run_in_env python -m pip install \
  "flash-attn==2.8.3" \
  --no-build-isolation

run_in_env python -m pip install \
  "vllm==0.19.1" \
  --extra-index-url "${PYTORCH_INDEX}"

run_in_env python -m pip install \
  --requirement "${ORARL_ROOT}/requirements-cu129.txt"

# One editable install covers the CLIs, the trainer runtime, and the evaluators.
# --no-deps keeps it from replacing the GPU stack pinned above.
run_in_env python -m pip install --no-deps --editable "${ORARL_ROOT}"
run_in_env python -m pip install "pytest" "ruff"

run_in_env bash "${ORARL_ROOT}/scripts/install_conda_runtime_hook.sh"
CHECK_ARGUMENTS=()
if [[ "${EVALUATION_ONLY}" -eq 1 ]]; then
  CHECK_ARGUMENTS+=(--evaluation-only)
fi
run_in_env bash -c \
  'source "${CONDA_PREFIX}/etc/conda/activate.d/orarl-runtime.sh"; shift; exec python "$@"' \
  _ "${ORARL_ROOT}/scripts/check_environment.py" "${CHECK_ARGUMENTS[@]}"

cat <<EOF

OraRL environment created successfully.

  conda activate ${ENV_NAME}
  python ${ORARL_ROOT}/scripts/check_environment.py --require-gpu
EOF