#!/bin/bash # Launch one long-lived, network-isolated container that runs campaign.py with # a fixed worker pool. Usage (host): # bash run_campaign.sh EPISODES.json OUTDIR WORKERS [NAME_SUFFIX] # EPISODES.json and OUTDIR must be inside the directory that contains runner/ (code/case1). # Any extra arguments after the suffix are passed to campaign.py. # tini (--init) reaps orphaned physics servers and forwards SIGTERM; TR_HOST_NAME enters the host fingerprint # written into every manifest and summary.json. # The exit code of campaign.py is the exit code of this script (0 complete, 3 stalled, 4 infrastructure errors # left after retries, 5 worker start failure, 130/143 interrupted). # Every path is resolved from this file's location (root = runner/..). The pinned image is run by its # content-addressed image Id, which survives `docker save | docker load` (a RepoDigest does not) and never triggers # a pull; the launcher refuses to run if that image is absent. TR_IMAGE_DIGEST (recorded in the code digest) keeps # the RepoDigest label. TR_MAX_WORKERS (default 12) is forwarded to campaign.py's worker cap. set -euo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" C="$(cd "$HERE/.." && pwd)" EPISODES="$(realpath "$1")"; OUT="$(realpath -m "$2")"; WORKERS="${3:-1}"; SUFFIX="${4:-$$}" shift $(( $# < 4 ? $# : 4 )) IMAGE="uwsbel/ros@sha256:60118a64d8e751c1adafef1abebebbc504a5814d63eae5bb46120de5f7b4554c" IMAGE_ID="sha256:73882e33184a5e9a586b5ce5167731ce0c569337104b273b05709a607730fa29" if ! docker image inspect "$IMAGE_ID" > /dev/null 2>&1; then echo "pinned image $IMAGE_ID ($IMAGE) is not present on $(hostname); load it first (docker load) - no pull is attempted" >&2; exit 2 fi case "$EPISODES" in "$C"/*) ;; *) echo "episodes file must be under $C" >&2; exit 2;; esac case "$OUT" in "$C"/*) ;; *) echo "output dir must be under $C" >&2; exit 2;; esac mkdir -p "$OUT" docker run --rm --init --network none --name "tr-c1-runner-$SUFFIX" \ --user "$(id -u):$(id -g)" -e HOME=/tmp -e TR_IMAGE_DIGEST="$IMAGE" -e TR_IMAGE_ID="$IMAGE_ID" \ -e TR_HOST_NAME="$(hostname)" -e TR_MAX_WORKERS="${TR_MAX_WORKERS:-12}" \ --cpus "$WORKERS" -v "$C:$C" -w "$HERE" --entrypoint /bin/bash "$IMAGE_ID" -c " set -e source /opt/ros/humble/setup.bash source /chrono_ros_interfaces/install/setup.bash source /sbel/Desktop/ros_ws/install/setup.bash export KERAS_BACKEND=torch CUDA_VISIBLE_DEVICES='' OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 export PYTHONWARNINGS=ignore PYTHONDONTWRITEBYTECODE=1 # CPU-dispatch pins. Verified bitwise no-ops on the host that ran the batches (AMD Ryzen 7 5800X). With # MKL_CBWR=COMPATIBLE, an Intel host (i9-14900KF) reproduced a 168-episode reference set bytewise. export ATEN_CPU_CAPABILITY=avx2 MKL_CBWR=COMPATIBLE OPENBLAS_CORETYPE=Haswell ONEDNN_MAX_CPU_ISA=AVX2 export NPY_DISABLE_CPU_FEATURES='AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL AVX512_SPR' exec python3 campaign.py --episodes '$EPISODES' --out '$OUT' --workers '$WORKERS' $* "