File size: 2,225 Bytes
9947c3c | 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 | #!/usr/bin/env python3
"""Preflight versions/imports/driver vs toolkit; no weights loaded or training."""
import argparse,importlib,json,os,platform,shutil,subprocess,sys
from pathlib import Path
ROOT=Path(__file__).absolute().parents[1]
MAP={'egoexo-generator':'egoexo/generator','egoexo-captioner-phiseg':'egoexo/captioner_and_phiseg','robot-sft-grpo':'robot/legacy_sft_grpo','robot-data-cpu':'robot/data_cpu'}
def main():
p=argparse.ArgumentParser(description=__doc__);p.add_argument('--profile',choices=MAP,required=True);p.add_argument('--gpu-basic-check',action='store_true');a=p.parse_args();folder=ROOT/MAP[a.profile];snapshot=json.loads((folder/'environment.snapshot.json').read_text())
result={'profile':a.profile,'python':platform.python_version(),'expected_python':snapshot['python'],'weights_loaded':False,'training_run':False,'modules':{}}
modules=['numpy','PIL','huggingface_hub'] if a.profile=='robot-data-cpu' else ['torch','torchvision','torchaudio','transformers','accelerate','safetensors']
if a.profile=='robot-sft-grpo':modules+=['verl','vllm','fla','tilelang']
if a.profile=='egoexo-captioner-phiseg':modules+=['swift']
for name in modules:
try:m=importlib.import_module(name);result['modules'][name]={'ok':True,'version':str(getattr(m,'__version__','unknown'))}
except Exception as e:result['modules'][name]={'ok':False,'error_type':type(e).__name__}
if 'torch' in sys.modules:
import torch
result.update(torch_cuda_runtime=torch.version.cuda,gpu_available=torch.cuda.is_available(),gpu_count=torch.cuda.device_count())
nvcc=shutil.which('nvcc');result['cuda_toolkit_nvcc_found']=bool(nvcc)
if nvcc:result['nvcc_version']=subprocess.check_output([nvcc,'--version'],text=True).strip().splitlines()[-2:]
if a.gpu_basic_check and torch.cuda.is_available():
x=torch.ones((2,2),device='cuda',dtype=torch.bfloat16);result['tiny_bfloat16_sum']=float(x.sum());torch.cuda.synchronize()
if a.profile=='robot-sft-grpo' and torch.cuda.device_count()<8:result['8GPU_GRPO_preconditions_met']=False
print(json.dumps(result,indent=2))
if result['python']!=result['expected_python'] or any(not x['ok'] for x in result['modules'].values()):raise SystemExit(1)
if __name__=='__main__':main()
|