-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpu_compute_check.py
More file actions
27 lines (21 loc) · 1.1 KB
/
Copy pathgpu_compute_check.py
File metadata and controls
27 lines (21 loc) · 1.1 KB
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
"""GPU compute check run on the AMD Developer Cloud hackathon pod.
Verifies the PyTorch stack is a ROCm build (not CUDA), prints the device
identity, and executes real GPU compute: a 4096x4096 matmul on the AMD
device. Output captured in gpu_compute_check_output.txt.
Runnable standalone on any ROCm machine: python amd/gpu_compute_check.py
"""
import torch
assert torch.version.hip, f"not a ROCm build: torch.version.hip={torch.version.hip!r}"
assert torch.version.cuda is None, f"CUDA build detected: torch.version.cuda={torch.version.cuda!r}"
assert torch.cuda.is_available(), "no ROCm device visible to torch"
props = torch.cuda.get_device_properties(0)
# get_device_name() returns an empty string on this RDNA3 card — gcnArchName
# is the authoritative identifier.
print(f"name: {props.name!r} | gcn: {props.gcnArchName} | VRAM GB: {props.total_memory / 2**30:.1f}")
torch.manual_seed(0)
a = torch.randn(4096, 4096, device="cuda")
b = torch.randn(4096, 4096, device="cuda")
c = a @ b
torch.cuda.synchronize()
print(f"matmul OK: {c.sum().item()}")
print(f"alloc MB: {torch.cuda.memory_allocated() // 2**20}")