diff --git a/scripts/run_agent_batch.sh b/scripts/run_agent_batch.sh index 844442045a..cdb6aa47ff 100755 --- a/scripts/run_agent_batch.sh +++ b/scripts/run_agent_batch.sh @@ -430,6 +430,15 @@ run_job() { # && ! python3 "$R/scripts/clamp_cpus.py" --cpus "$HOST_CPUS" --needs "${dirs[@]}" >/dev/null \ || { log "FAILED $job: could not clamp its CPU caps to the host's $HOST_CPUS ($root); not started"; rm -rf "$root"; return 1; } fi + # short-form run, runner-side GPU placement: pin this lane's GPU requests to one card in the job's own copy (tasks/ untouched). + # As shipped every task asks for "count: 1" and Docker hands out the first GPU each time. + if [ -n "${GPU_DEVICE:-}" ]; then + mapfile -t dirs < <(task_dirs "$root" "$@") + for f in "${dirs[@]}"; do + [ -f "$f/environment/docker-compose.yaml" ] && sed -i -E "s/^( *)count: 1\$/\\1device_ids: [\"$GPU_DEVICE\"]/" "$f/environment/docker-compose.yaml" + done + log "[$job] GPU requests pinned to device $GPU_DEVICE" + fi stamp_task_dirs "$root" || { log "FAILED $job: could not stamp its task copy (scripts/stamp_mtimes.py, $root); not started"; rm -rf "$root"; return 1; } # the copies' digests next to the job (scripts/write_task_results.py): a trial of a copy the runner changed (egress, CPU caps) # is a trial of the task's current DIGEST, not of another version