Editing
Ai Hardware
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Profiling GPU utilization and identifying bottlenecks:''' <syntaxhighlight lang="python"> import torch from torch.profiler import profile, ProfilerActivity, tensorboard_trace_handler # Profile a model training step model = MyTransformerModel().cuda() optimizer = torch.optim.Adam(model.parameters()) inputs = torch.randn(32, 512).cuda() # batch=32, seq_len=512 with profile( activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA], schedule=torch.profiler.schedule(wait=1, warmup=1, active=3), on_trace_ready=tensorboard_trace_handler("./log/profiler"), record_shapes=True, profile_memory=True, with_stack=True ) as prof: for step in range(5): optimizer.zero_grad() loss = model(inputs).sum() loss.backward() optimizer.step() prof.step() # Print top CUDA kernels by time print(prof.key_averages().table(sort_by="cuda_time_total", row_limit=10)) </syntaxhighlight> '''Enabling mixed precision training (automatic):''' <syntaxhighlight lang="python"> from torch.cuda.amp import autocast, GradScaler scaler = GradScaler() for batch in dataloader: optimizer.zero_grad() with autocast(dtype=torch.bfloat16): # BF16 on H100 (preferred over FP16) output = model(batch) loss = criterion(output, targets) scaler.scale(loss).backward() scaler.step(optimizer) scaler.update() </syntaxhighlight> ; AI chip selection guide : '''Research / single GPU''' β NVIDIA RTX 4090 (24GB, consumer) or A6000 (48GB, workstation) : '''Production training''' β NVIDIA H100 (80GB HBM3, 3.35 TB/s bandwidth), clusters of 8β1024 : '''Google Cloud training''' β TPU v4/v5 pods (purpose-built for large-scale training) : '''Edge inference (mobile)''' β Apple Neural Engine (ANE), Qualcomm Hexagon DSP : '''Edge inference (industrial)''' β NVIDIA Jetson Orin, Hailo-8, Coral Edge TPU : '''Data center inference''' β NVIDIA H100/L40S, Groq LPU (ultra-low latency), Cerebras </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information