DynaTTT / scripts /check_sapien_gpu.py
DanTim05's picture
Upload Zeva source and project assets
68eed61 verified
Raw History Blame Contribute Delete
1.19 kB
"""Fail before rollout if legacy SAPIEN maps CUDA to the wrong physical GPU."""
import argparse
import os
import subprocess
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--expected-uuid', required=True)
args = parser.parse_args()
import sapien.core as sapien
engine = sapien.Engine()
renderer = sapien.SapienRenderer(device='cuda:0', offscreen_only=True)
engine.set_renderer(renderer)
lines = subprocess.check_output([
'nvidia-smi', '--query-compute-apps=gpu_uuid,pid', '--format=csv,noheader'
], text=True).splitlines()
actual = {uuid.strip() for uuid, pid in (line.split(',') for line in lines)
if pid.strip() == str(os.getpid())}
if actual != {args.expected_uuid}:
raise RuntimeError(
f'SAPIEN physical GPU mismatch: expected {args.expected_uuid}, got {sorted(actual)}. '
'This legacy renderer can confuse equal PCI bus numbers in different domains. '
'No rollout was started; choose a verified free renderer GPU.'
)
print(f'SAPIEN_GPU_VERIFIED uuid={args.expected_uuid}', flush=True)
if __name__ == '__main__':
main()