Download scripts/check_sapien_gpu.py from DanTim05/DynaTTT: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/spaces/DanTim05/DynaTTT/resolve/main/scripts/check_sapien_gpu.py
- Command line
-
hf download hf://spaces/DanTim05/DynaTTT/scripts/check_sapien_gpu.py
-
curl -L -o check_sapien_gpu.py https://huggingface.co/spaces/DanTim05/DynaTTT/resolve/main/scripts/check_sapien_gpu.py
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() | |