#!/bin/bash # setup_env.sh — reproduce the authors' stack for StBR / SPOT on D4RL hopper-medium-v2. # Mirrors StBR's conda_env.yml (repo pinned at c47ebe2bf1c4bc801a225c8b86ae00917e7e706a): # python=3.8.5, pytorch>=2.1.0 (pytorch-cuda=12.1), gym==0.18.3, mujoco-py, # numpy<1.24.0, pyyaml==5.4.1, coolname==1.1.0, termcolor==1.1.0, # tensorboard==2.7.0, protobuf==3.17.3 # + MuJoCo 2.1.0 at ~/.mujoco/mujoco210 (StBR README step 1) # + d4rl pinned at the exact commit linked in the StBR README: # 4aff6f8c46f62f9a57f79caa9287efefa45b6688 # NOTE: SPOT's own conda_env.yml pins torch 1.10.0 + cudatoolkit 10.x, which cannot # run on modern GPUs (T4/L4/A10G). We run SPOT under this (StBR) environment — SPOT is # plain PyTorch and its training hyperparameters are untouched. Disclosed as a scale-down. # Base OS: ubuntu:22.04 (Debian 11 mirrors are EOL since Aug 2026). # gym 0.18.3 caps Pillow<=8.2.0; imageio>=2.10.5 floors pillow>=8.3.2 -> imageio # pinned to 2.9.0 (last release without a pillow pin; also what the authors' `anaconda` # metapackage shipped on py3.8.5). Failed builds archived in logs/failed/. set -euxo pipefail export DEBIAN_FRONTEND=noninteractive apt-get update -q apt-get install -yq --no-install-recommends \ git curl wget bzip2 ca-certificates build-essential pkg-config \ libgl1-mesa-dev libosmesa6-dev libglew-dev \ libglfw3 libglfw3-dev patchelf libegl1 rm -rf /var/lib/apt/lists/* # --- Miniconda (provides `defaults` channel, which still hosts python=3.8.5) --- if [ ! -x /opt/conda/bin/conda ]; then wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh bash /tmp/miniconda.sh -b -p /opt/conda fi source /opt/conda/etc/profile.d/conda.sh # --- MuJoCo 2.1.0 (StBR README step 1) --- mkdir -p ~/.mujoco if [ ! -d ~/.mujoco/mujoco210 ]; then wget -q https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz -O /tmp/mujoco210.tar.gz tar -zxf /tmp/mujoco210.tar.gz -C ~/.mujoco/ fi cat > /root/stbr_env.rc <<'EOF' export LD_LIBRARY_PATH=$HOME/.mujoco/mujoco210/bin:/usr/lib/nvidia:${LD_LIBRARY_PATH:-} export MUJOCO_PY_MUJOCO_PATH=$HOME/.mujoco/mujoco210 export D4RL_SUPPRESS_IMPORT_ERROR=1 EOF source /root/stbr_env.rc # --- conda env: python 3.8.5 (StBR conda_env.yml) --- # newer conda requires accepting Anaconda's ToS for the defaults channel /opt/conda/bin/conda tos accept --override-channels \ --channel https://repo.anaconda.com/pkgs/main --channel https://repo.anaconda.com/pkgs/r || true conda create -y -n stbr python=3.8.5 conda activate stbr pip install --upgrade pip==24.0 setuptools==59.5.0 wheel==0.37.1 # PyTorch >= 2.1 with CUDA 12.1 (pytorch-cuda=12.1 equivalent; pip cu121 wheels) pip install torch==2.4.1 --index-url https://download.pytorch.org/whl/cu121 # Core deps from conda_env.yml (pip section) pip install numpy==1.23.5 gym==0.18.3 "cython<3" mujoco-py==2.1.2.14 \ pyyaml==5.4.1 coolname==1.1.0 termcolor==1.1.0 tensorboard==2.7.0 \ protobuf==3.17.3 tqdm==4.61.2 imageio==2.9.0 h5py==3.8.0 \ click cloudpickle==1.6.0 pyglet==1.5.0 scipy matplotlib==3.7.5 # modern gymnasium + mujoco (ONLY for Step-3 MP4 rendering; unused by training) pip install gymnasium==0.29.1 mujoco==2.3.7 imageio-ffmpeg # d4rl pinned at the commit linked in the StBR README. Installed --no-deps: # its setup.py would pull pybullet/dm_control/mjrl (git URLs) which only matter for # non-MuJoCo domains; d4rl/__init__.py wraps every domain import in try/except. pip install --no-deps "git+https://github.com/rail-berkeley/d4rl.git@4aff6f8c46f62f9a57f79caa9287efefa45b6688" # --- verification --- python -c "import mujoco_py; print('mujoco-py OK', mujoco_py.__version__)" python -c "import torch; print('torch OK', torch.__version__, 'cuda:', torch.cuda.is_available(), torch.cuda.get_device_name(0) if torch.cuda.is_available() else '')" python -c "import gym, d4rl; env = gym.make('hopper-medium-v2'); print('d4rl env OK:', env.spec.id)" echo "ENV SETUP DONE"