()
| 7 | |
| 8 | @app.function(gpu="B200", image=make_image()) |
| 9 | def ncu_test(): |
| 10 | script = """ |
| 11 | import torch |
| 12 | |
| 13 | a = torch.randn(1024, 1024, device="cuda", dtype=torch.bfloat16) |
| 14 | b = torch.randn(1024, 1024, device="cuda", dtype=torch.bfloat16) |
| 15 | torch.cuda.synchronize() |
| 16 | c = a + b |
| 17 | torch.cuda.synchronize() |
| 18 | """ |
| 19 | with open("/tmp/ncu_kernel.py", "w") as f: |
| 20 | f.write(script) |
| 21 | |
| 22 | result = subprocess.run( |
| 23 | [ |
| 24 | "ncu", |
| 25 | "--target-processes", |
| 26 | "all", |
| 27 | "--set", |
| 28 | "basic", |
| 29 | "python", |
| 30 | "/tmp/ncu_kernel.py", |
| 31 | ], |
| 32 | capture_output=True, |
| 33 | text=True, |
| 34 | ) |
| 35 | print("=== stdout ===") |
| 36 | print(result.stdout[-3000:] if len(result.stdout) > 3000 else result.stdout) |
| 37 | print("=== stderr ===") |
| 38 | print(result.stderr[-3000:] if len(result.stderr) > 3000 else result.stderr) |
| 39 | print(f"=== returncode: {result.returncode} ===") |
| 40 | |
| 41 | |
| 42 | @app.local_entrypoint() |
nothing calls this directly
no outgoing calls
no test coverage detected