Zion Boggan
repos/GPU CPU Mutex/gpu_run.sh
zionboggan.com ↗
15 lines · bash
History for this file →
1
LOCK="${GPU_LOCK_PATH:-/tmp/gpu.lock}"
2
 
3
if [ -n "${GPU_LOCK_HELD:-}" ]; then
4
  exec "$@"
5
fi
6
 
7
exec 9>"$LOCK"
8
echo "[gpu_run] waiting for GPU lock..." >&2
9
flock 9
10
echo "[gpu_run] acquired GPU lock → running: $*" >&2
11
export GPU_LOCK_HELD=1
12
"$@"
13
rc=$?
14
echo "[gpu_run] done (rc=$rc), releasing GPU lock" >&2
15
exit $rc