Download code/modal/gpu_smoke.py from PratikBuilds/modelclinic-experiment-001: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/datasets/PratikBuilds/modelclinic-experiment-001/resolve/main/code/modal/gpu_smoke.py
- Command line
-
hf download hf://datasets/PratikBuilds/modelclinic-experiment-001/code/modal/gpu_smoke.py
-
curl -L -o gpu_smoke.py https://huggingface.co/datasets/PratikBuilds/modelclinic-experiment-001/resolve/main/code/modal/gpu_smoke.py
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') | |
| 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])} | |
| 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)) | |