CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # C5 sharing and recovery on a GB10 (docs/OMEGA.md row C5), one hold of the GB10 lock: |
| 4 | # 01 values build/gpu_isolation_test --values-only: our two processes side by side, both right |
| 5 | # 02 mutant build/gpu_isolation_test_mutant --values-only: red control, the values check must fail (exit 1) |
| 6 | # 03 hang build/gpu_isolation_test (chip tier): never-ending kernel times out, latch refusal (red check), |
| 7 | # recover, correct launches in the same process, stale command list refused (red check), two |
| 8 | # processes, and a hang in one process beside a working one |
| 9 | # 04 cuda build/c5_matrix c: our two processes beside a CUDA (PyTorch) process |
| 10 | # 05 pressure build/c5_matrix p: the same while the CUDA process holds 16 GiB of device memory |
| 11 | # 06 kill build/c5_matrix k: our process SIGKILLed 500 ms into its never-ending launch beside a CUDA process |
| 12 | # 07 red build/c5_matrix r: the CUDA process against a wrong expectation must exit 1 |
| 13 | # 08 health build/gpu_isolation_test --values-only again, after everything |
| 14 | # Kernel log lines added during the hold go to dmesg.txt; Xid / NVRM / watchdog lines to xid.txt. |
| 15 | # |
| 16 | # tools/c5/build.sh (outside the lock, or the c5-sharing workflow artifact) |
| 17 | # tools/c5/chip.sh OUTDIR (takes /tmp/aien-gb10.lock itself) |
| 18 | # Exit 0 only when every step ended as expected. |
| 19 | set -u |
| 20 | OUT=${1:?usage: tools/c5/chip.sh OUTDIR} |
| 21 | B=${BUILD:-build} |
| 22 | PY=${PY:-$HOME/.venv/bin/python} |
| 23 | LOCK=${LOCK:-/tmp/aien-gb10.lock} |
| 24 | for f in "$B/gpu_isolation_test" "$B/gpu_isolation_test_mutant" "$B/c5_matrix"; do |
| 25 | [ -x "$f" ] || { echo "NOT_RUN: $f is not built" >&2; exit 2; } |
| 26 | done |
| 27 | [ -x "$PY" ] || { echo "NOT_RUN: no Python at $PY for the CUDA tenant" >&2; exit 2; } |
| 28 | mkdir -p "$OUT" |
| 29 | S="$OUT/summary.txt" |
| 30 | { |
| 31 | sha256sum "$B/gpu_isolation_test" "$B/gpu_isolation_test_mutant" "$B/c5_matrix" |
| 32 | echo "driver $(cat /sys/module/nvidia/version 2>/dev/null || echo unknown)" |
| 33 | echo "cuda tenant $("$PY" -c 'import torch; print("torch", torch.__version__, "cuda", torch.version.cuda)' 2>&1 | tail -1)" |
| 34 | } > "$S" |
| 35 | |
| 36 | exec 9>"$LOCK" |
| 37 | flock -w 900 9 || { echo "NOT_RUN: GB10 lock busy for 900 s" >&2; exit 2; } |
| 38 | echo "start $(date -u +%Y-%m-%dT%H:%M:%SZ) loadavg $(cat /proc/loadavg)" >> "$S" |
| 39 | # the kernel ring buffer is full and rotates, so a line-count baseline loses lines: filter by timestamp instead |
| 40 | since=$(date +%Y-%m-%dT%H:%M:%S,%6N) |
| 41 | fails=0 |
| 42 | step() { # name want_rc command... |
| 43 | name=$1; want=$2; shift 2 |
| 44 | log="$OUT/$name.log" |
| 45 | { echo "loadavg $(cat /proc/loadavg)"; echo "cmd $*"; } > "$log" |
| 46 | rc=0 |
| 47 | timeout -k 10 300 "$@" >> "$log" 2>&1 || rc=$? |
| 48 | echo "exit $rc" >> "$log" |
| 49 | v=$(grep -E '^C5 (isolation|matrix)' "$log" | tail -1) |
| 50 | if [ "$rc" -eq "$want" ]; then r=ok; else r=FAIL; fails=$((fails + 1)); fi |
| 51 | echo "$r $name exit $rc (want $want) ${v:-no verdict line}" >> "$S" |
| 52 | } |
| 53 | step 01-values 0 "$B/gpu_isolation_test" --values-only |
| 54 | step 02-mutant 1 "$B/gpu_isolation_test_mutant" --values-only |
| 55 | step 03-hang 0 "$B/gpu_isolation_test" |
| 56 | step 04-cuda 0 "$B/c5_matrix" "$(pwd)/$B/gpu_isolation_test" "$PY" c |
| 57 | step 05-pressure 0 "$B/c5_matrix" "$(pwd)/$B/gpu_isolation_test" "$PY" p |
| 58 | step 06-kill 0 "$B/c5_matrix" "$(pwd)/$B/gpu_isolation_test" "$PY" k |
| 59 | step 07-red 0 "$B/c5_matrix" "$(pwd)/$B/gpu_isolation_test" "$PY" r |
| 60 | # the red control counts only when the values check is what failed: wrong values reported, not a setup error |
| 61 | if grep -qE 'FAIL: process [12]: .* [1-9][0-9]* wrong values' "$OUT/02-mutant.log"; then |
| 62 | echo "ok 02-mutant red because of wrong values" >> "$S" |
| 63 | else |
| 64 | echo "FAIL 02-mutant did not fail on wrong values" >> "$S"; fails=$((fails + 1)) |
| 65 | fi |
| 66 | step 08-health 0 "$B/gpu_isolation_test" --values-only |
| 67 | sudo -n dmesg --time-format iso 2>/dev/null | awk -v s="$since" '$1 >= s' > "$OUT/dmesg.txt" |
| 68 | grep -E 'Xid|NVRM|watchdog|GPU has fallen|nvidia' "$OUT/dmesg.txt" > "$OUT/xid.txt" || true |
| 69 | nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv > "$OUT/compute-apps-after.txt" 2>&1 || true |
| 70 | flock -u 9 |
| 71 | { |
| 72 | echo "end $(date -u +%Y-%m-%dT%H:%M:%SZ)" |
| 73 | echo "kernel log lines during the hold: $(wc -l < "$OUT/dmesg.txt"), Xid/NVRM/watchdog lines: $(wc -l < "$OUT/xid.txt")" |
| 74 | echo "checks not as expected: $fails of 9 (8 steps and the mutant's cause)" |
| 75 | } >> "$S" |
| 76 | cat "$S" |
| 77 | [ "$fails" -eq 0 ] |