PratikBuilds's picture
Publish initial ModelClinic Experiment 001 archive
87cc7f2 verified
Raw History Blame Contribute Delete
1.42 kB
"""Bounded Modal L4 CUDA preflight. Not a behavioral experiment.
Run only after `modal token info` and `modal billing rates` succeed.
No volume or endpoint is created. Image build may incur CPU/network charges.
"""
import json
import modal
app = modal.App('modelclinic-gpu-preflight')
image = modal.Image.debian_slim(python_version='3.11').pip_install('torch==2.8.0')
@app.function(image=image, gpu=['L4','A10'], timeout=120, scaledown_window=2)
def gpu_check():
import torch
assert torch.cuda.is_available(), 'CUDA unavailable'
assert torch.cuda.is_bf16_supported(), 'BF16 unavailable'
a = torch.ones((256, 256), device='cuda', dtype=torch.bfloat16)
result = a @ a
torch.cuda.synchronize()
assert float(result[0, 0]) == 256.0
free, total = torch.cuda.mem_get_info()
return {'gpu':torch.cuda.get_device_name(), 'vram_total_bytes':total,
'vram_free_bytes':free, 'allocated_bytes':torch.cuda.memory_allocated(),
'torch_version':torch.__version__, 'cuda_version':torch.version.cuda,
'bf16_supported':torch.cuda.is_bf16_supported(), 'tensor_result':float(result[0,0])}
@app.local_entrypoint()
def main():
from pathlib import Path
result = gpu_check.remote()
Path('results/checkpoint_analysis/modal_gpu_smoke.json').write_text(json.dumps(result, indent=2))
print(json.dumps(result, indent=2))