Repository navigation
[CI] Re-enable multi-GPU tests on two-GPU runners #8275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
a250aaf
e61d7a5
80c1d9b
67bc9a2
af9119b
2a2d654
0c2c416
824fcdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,43 +57,51 @@ else | |
| DEV_COUNT=$GPU_COUNT | ||
| echo "::notice::container: discrete mode, $GPU_COUNT GPUs" | ||
| fi | ||
| if [ "$DEV_COUNT" -lt 2 ]; then | ||
| echo "::error::Need at least 2 visible devices; found $DEV_COUNT" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Cross-check with torch and cap shard count to what torch can actually | ||
| # address. Guards against a CUDA_VISIBLE_DEVICES misconfig silently fanning | ||
| # out shards that crash on device access. | ||
| TORCH_COUNT=$(/isaac-sim/python.sh -c "import torch; print(torch.cuda.device_count())") | ||
| # torch lives in the image's venv, not Kit's bundled Python, so resolve it the way the shards do. | ||
| TORCH_COUNT=$(uv run --no-sync isaaclab -p -c "import torch; print(torch.cuda.device_count())" | tail -n1) | ||
| if ! [[ "$TORCH_COUNT" =~ ^[0-9]+$ ]]; then | ||
| echo "::error::Could not read torch.cuda.device_count(); got '$TORCH_COUNT'" | ||
| exit 1 | ||
| fi | ||
| echo "container: torch sees $TORCH_COUNT cuda devices (cross-check vs $DEV_COUNT)" | ||
| if [ "$TORCH_COUNT" -lt "$DEV_COUNT" ]; then | ||
| echo "::warning::torch sees fewer devices than nvidia-smi β capping shards to $TORCH_COUNT" | ||
| DEV_COUNT=$TORCH_COUNT | ||
| fi | ||
| if [ "$DEV_COUNT" -lt 2 ]; then | ||
| echo "::error::Need at least 2 visible devices; found $DEV_COUNT" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Fan out 1 pytest subshell per non-default cuda:N. Each gets its own HOME | ||
| # (per-shard isolation for .cache, .local/share, etc.) and per-shard | ||
| # ISAACLAB_TEST_DEVICES. | ||
| declare -A pids # associative array: shard index -> background PID | ||
| for ((cuda = 1; cuda < DEV_COUNT; cuda++)); do # C-style loop; start at 1 to skip cuda:0 (single-GPU CI covers it) | ||
| zeros="" | ||
| # Fan out 1 pytest subshell per shard. Each gets its own HOME (per-shard | ||
| # isolation for .cache, .local/share, etc.) and per-shard ISAACLAB_TEST_DEVICES. | ||
| # launch_shard <name> <cuda> [<CUDA_VISIBLE_DEVICES>] | ||
| declare -A pids # associative array: shard name -> background PID | ||
| launch_shard() { | ||
| local name="$1" cuda="$2" cvd="${3:-}" | ||
| local zeros="" | ||
| for ((i = 0; i <= cuda; i++)); do zeros+="0"; done # build the leading zeros of the device mask | ||
| runtime_devices="${zeros}1" # e.g. cuda:2 -> "0001": only this GPU active in the ISAACLAB_TEST_DEVICES mask | ||
| local runtime_devices="${zeros}1" # e.g. cuda:2 -> "0001": only this GPU active in the ISAACLAB_TEST_DEVICES mask | ||
|
|
||
| shard_home="/tmp/isaaclab-ci-home-${cuda}" | ||
| local shard_home="/tmp/isaaclab-ci-home-${name}" | ||
| mkdir -p "${shard_home}/.cache" "${shard_home}/.local/share" \ | ||
| "${shard_home}/.nvidia-omniverse/config" \ | ||
| "${shard_home}/.nvidia-omniverse/logs" | ||
|
|
||
| shard_log="/shard-logs/cuda-${cuda}.log" | ||
| local shard_log="/shard-logs/cuda-${name}.log" | ||
|
|
||
| # each shard runs in its own subshell, backgrounded with '&' below, so all shards run in parallel | ||
| ( | ||
| export HOME="$shard_home" | ||
| export XDG_CACHE_HOME="${HOME}/.cache" | ||
| export XDG_DATA_HOME="${HOME}/.local/share" | ||
| export ISAACLAB_TEST_DEVICES="$runtime_devices" | ||
| export ISAACLAB_TEST_QUEUE_SHARD="cuda-${name}" # done/<shard>/ in the queue, so the summary splits shards | ||
| [ -z "$cvd" ] || export CUDA_VISIBLE_DEVICES="$cvd" | ||
|
|
||
| # Full pytest output captures to $shard_log; live stdout is filtered | ||
| # down to high-signal lines (test boundaries, failures, summary stats, | ||
|
|
@@ -110,17 +118,31 @@ for ((cuda = 1; cuda < DEV_COUNT; cuda++)); do # C-style loop; start at 1 to sk | |
| | tee "$shard_log" \ | ||
| | stdbuf -oL grep -aE \ | ||
| 'π|^source/.*::.* (PASSED|FAILED|ERROR|SKIPPED|XFAIL|XPASS)|^(Total|Passing|Failing|Crashed|Startup Hang|Timeout|Total Wall Time|Total Test Time|Passing Percentage):|^~~~~|^=+ |^E +|^ +File |Traceback|^FAILED|^ERROR ' \ | ||
| | stdbuf -oL sed "s/^/[cuda:${cuda}] /" | ||
| | stdbuf -oL sed "s/^/[cuda:${name}] /" | ||
|
|
||
| exit "${PIPESTATUS[0]}" # exit with pytest's code, not tee/grep/sed's (PIPESTATUS[0] = first pipe stage) | ||
| ) & | ||
| pids[$cuda]=$! # $! = PID of the subshell just backgrounded | ||
| echo "::notice::launched shard cuda:${cuda} (pid ${pids[$cuda]}, runtime_devices=$runtime_devices)" | ||
| pids[$name]=$! # $! = PID of the subshell just backgrounded | ||
| echo "::notice::launched shard cuda:${name} (pid ${pids[$name]}, runtime_devices=$runtime_devices${cvd:+, CUDA_VISIBLE_DEVICES=$cvd})" | ||
| } | ||
|
|
||
| for ((cuda = 1; cuda < DEV_COUNT; cuda++)); do # start at 1: a shard tests a non-default device index | ||
| launch_shard "$cuda" "$cuda" | ||
| done | ||
|
|
||
| # Physical GPU 0 would idle, since single-GPU CI covers cuda:0. Swapping the first two visible | ||
| # devices makes it this shard's cuda:1, so it still tests a non-default index. | ||
| if [ -n "${CUDA_VISIBLE_DEVICES:-}" ]; then | ||
| IFS=',' read -ra visible <<< "$CUDA_VISIBLE_DEVICES" | ||
| else | ||
| mapfile -t visible < <(seq 0 $((DEV_COUNT - 1))) | ||
| fi | ||
| swapped=("${visible[1]}" "${visible[0]}" "${visible[@]:2}") | ||
| launch_shard "1-gpu0" 1 "$(IFS=,; echo "${swapped[*]}")" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π΅ Suggestion Β· Implementation β Extra shard ignores torch device cap The torch cross-check can lower
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 127d9f44286: the two-device minimum now runs after the torch cap, so the extra shard never launches with fewer than two devices. |
||
|
|
||
| # Wait for every shard before aggregating exits β a fast failure must not | ||
| # tear down still-running siblings. | ||
| declare -A results # associative array: shard index -> exit code | ||
| declare -A results # associative array: shard name -> exit code | ||
| for cuda in "${!pids[@]}"; do # "${!pids[@]}" = the array's keys (the shard indices) | ||
| wait "${pids[$cuda]}" # block until that shard's PID exits | ||
| results[$cuda]=$? # $? = the waited shard's exit code | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the original shard and
1-gpu0selectcuda:1. The queue names shards fromresolve_test_sim_device(), not the name passed tolaunch_shard, so both GPUs put completed files underdone/cuda-1. The summary combines them into one row, hiding which files ran on physical GPU 0. Pass a separate shard identifier to the queue helpers so each GPU has its own summary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 127d9f44286: each shard exports
ISAACLAB_TEST_QUEUE_SHARD(cuda-1,cuda-1-gpu0) andtools/conftest.pyfiles its queue claims under it, so the summary has one row per physical GPU.