File size: 1,315 Bytes
fb0074a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# Optional local GPU-holder lifecycle. Never enabled merely because files exist.
set -Eeuo pipefail
MANAGE_GPU_MONITOR=${HFD_MANAGE_GPU_MONITOR:-0}
GPU_MONITOR_ROOT=${HFD_GPU_MONITOR_ROOT:-/cpfs01/thscc/sharestorage/AIGC-06-01/Hithink_VideoGen_Group/user_workspace/yetinghong/code/monitor}
MONITOR_CMD=$GPU_MONITOR_ROOT/cmd.sh
MONITOR_SCRIPT=$GPU_MONITOR_ROOT/monitor.sh
MONITOR_PY=$GPU_MONITOR_ROOT/monitor.py
MONITOR_GUARD_PID=
MONITOR_GUARD_SECONDS=${HFD_MONITOR_GUARD_SECONDS:-5}
stop_gpu_monitor() {
  pkill -f "$MONITOR_SCRIPT" 2>/dev/null || true
  pkill -f "$MONITOR_PY" 2>/dev/null || true
}
guard_gpu_monitor() {
  while true; do
    stop_gpu_monitor
    sleep "$MONITOR_GUARD_SECONDS"
  done
}
restore_gpu_monitor() {
  if [[ -n "${MONITOR_GUARD_PID:-}" ]]; then
    kill "$MONITOR_GUARD_PID" 2>/dev/null || true
    wait "$MONITOR_GUARD_PID" 2>/dev/null || true
  fi
  if [[ -f "$MONITOR_CMD" ]]; then
    set +e
    stop_gpu_monitor
    source "$MONITOR_CMD"
    set -e
  fi
}
# DLC does not need a GPU holder. Only an explicit local opt-in may stop or
# restore this user's monitor; shared storage containing cmd.sh is not consent.
if [[ "$MANAGE_GPU_MONITOR" == "1" ]]; then
  trap restore_gpu_monitor EXIT
  stop_gpu_monitor
  guard_gpu_monitor &
  MONITOR_GUARD_PID=$!
fi

"$@"