When planning GPU infrastructure for machine learning, key metrics include throughput (how many tasks the GPUs can handle per time), latency (how fast each task completes), and utilization (how busy the GPUs are). These metrics help decide how many GPUs are needed and how powerful they should be. For example, high throughput means more models or data can be processed quickly. High utilization means the GPUs are used well without wasting resources.
GPU infrastructure planning in Prompt Engineering / GenAI - Model Metrics & Evaluation
Start learning this pattern below
Jump into concepts and practice - no test required
GPU planning does not use a confusion matrix like classification models. Instead, visualize resource usage with a GPU utilization chart showing busy vs idle times, or a throughput graph showing tasks completed per second. For example:
Time (min) | GPU Utilization (%)
-----------------------------
0 | 20
1 | 50
2 | 90
3 | 85
4 | 95
This helps see if GPUs are underused or overloaded.
Think of precision as avoiding wasted GPU time (not running unnecessary tasks), and recall as making sure all needed tasks get done quickly. If you add too many GPUs, you have high recall (all tasks done fast) but low precision (some GPUs sit idle). If you have too few GPUs, you have high precision (no waste) but low recall (tasks wait too long). The goal is to balance so GPUs are busy but not overloaded.
- Good: GPU utilization around 70-90%, throughput meets task demand, latency is low enough for your needs.
- Bad: Utilization below 30% (wasting money), or above 95% (risking slowdowns), throughput too low causing delays, or latency too high for real-time needs.
- Ignoring peak usage times and only looking at average utilization can hide bottlenecks.
- Not accounting for data transfer times between CPU and GPU, which can slow down tasks.
- Overfitting to current workloads without planning for future growth.
- Confusing high utilization with good performance; sometimes GPUs are busy but slow due to inefficient code.
Your GPU cluster shows 98% utilization but tasks are taking too long to finish. Is this good? Why or why not?
Answer: No, this means GPUs are overloaded. High utilization with slow tasks suggests bottlenecks. You may need more GPUs or optimize code to reduce task time.
Practice
Solution
Step 1: Understand GPU role in AI projects
GPUs speed up AI model training and need enough memory to handle data.Step 2: Importance of matching GPU specs to model needs
Choosing a GPU with insufficient memory or speed will slow down or fail the project.Final Answer:
To ensure the GPU has enough memory and speed for the AI model -> Option BQuick Check:
GPU specs must match AI needs = D [OK]
- Thinking CPUs can replace GPUs for heavy AI tasks
- Assuming all GPUs have the same performance
- Ignoring GPU memory limits
Solution
Step 1: Recall PyTorch GPU memory query syntax
The correct method is torch.cuda.get_device_properties(device_id).total_memory.Step 2: Check each option for correctness
Only torch.cuda.get_device_properties(0).total_memory uses the correct PyTorch function and attribute.Final Answer:
torch.cuda.get_device_properties(0).total_memory -> Option CQuick Check:
Correct PyTorch GPU memory call = C [OK]
- Using non-existent PyTorch functions
- Confusing device and memory functions
- Missing the device index argument
import torch
if torch.cuda.is_available():
mem = torch.cuda.get_device_properties(0).total_memory
print(mem > 8_000_000_000)
else:
print(False)Solution
Step 1: Understand the code logic
The code checks if a GPU is available, then compares its memory to 8GB (8 billion bytes).Step 2: Determine output based on GPU memory
If GPU memory is greater than 8GB, it prints True; otherwise, False. If no GPU, prints False.Final Answer:
True if GPU memory is more than 8GB, else False -> Option AQuick Check:
GPU memory check > 8GB = A [OK]
- Assuming always True regardless of GPU
- Expecting error if no GPU instead of False
- Confusing bytes with gigabytes
import torch
if torch.cuda.is_available():
mem = torch.cuda.get_device_properties().total_memory
print(mem)
else:
print('No GPU')Solution
Step 1: Check get_device_properties usage
The function requires a device index argument, e.g., 0 for the first GPU.Step 2: Identify the fix
Adding (0) fixes the error. Other options are incorrect or unnecessary.Final Answer:
Add device index 0 in get_device_properties: get_device_properties(0) -> Option AQuick Check:
Missing device index causes error = B [OK]
- Omitting device index argument
- Using non-existent torch.has_cuda()
- Confusing memory functions
Solution
Step 1: Analyze GPU memory requirement vs available hardware
The model needs 24GB, but local GPUs have only 16GB, so one GPU is insufficient.Step 2: Consider solutions for insufficient GPU memory
Using multiple GPUs with model parallelism or cloud GPUs with enough memory solves the problem effectively.Final Answer:
Use multiple GPUs with model parallelism or switch to cloud GPUs with 24GB+ memory -> Option DQuick Check:
Match GPU memory to model needs with parallelism or cloud = A [OK]
- Trying to train large models on insufficient GPU memory
- Ignoring cloud GPU options
- Assuming CPU can replace GPU for large models
